Bimal Bhandari
Bimal Bhandari

Reputation: 33

Auto refreshing the page when it is visited after some duration of time

Can it be possible to auto-refresh a page when visiting to its tab after some duration of time. I am asking in the case of opening many tabs in the browser and the tab where our web page is running need to be auto-refreshed when coming back to it from the other tab

Upvotes: 1

Views: 839

Answers (2)

Vidyadhar
Vidyadhar

Reputation: 1118

Below code will do the trick

$(window).on('focus', function() { 
    /*your code*/
    setTimeout(function(){
        location.reload();//will reload your page
    },1000); //duration
}); 

Upvotes: 1

Nikunj Chotaliya
Nikunj Chotaliya

Reputation: 802

You can try this.

<meta http-equiv="refresh" content="30">

Refresh document every 30 seconds:

So try this.

or this. may solve your problem.

Upvotes: 1

Related Questions