Is it possible to have a visualforce page refresh/rerender when the browser focus returns to the page? Anybody have any quick script code or anything that accomplishes this?
1 Answer
The script:
window.addEventListener('focus', function() { callActionFunction() });
The page that demonstrates the script:
Class
public class renderCount {
public Integer counter { get; set; }
public renderCount() {
counter = 0;
}
public void reRender() {
counter++;
}
}
Page
<apex:page controller="renderCount">
<script>
window.addEventListener('focus', function() { callActionFunction() });
</script>
<apex:form id="form">
<apex:actionFunction name="callActionFunction" action="{!reRender}" reRender="form" />
<apex:outputText value="{!counter}" />
</apex:form>
</apex:page>