1

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 1

2

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>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .