JQuery: setting page timeout for loading

I would like to make a script that detects if the page is loaded at 30 or refresh the page using the (CTRL + F5) method of Firefox, which clears the cache of this page and refreshes. Can I do it? PS: If you can’t do it in jQuery, I can use regular javascript. Thanks in advance. Sincerely. Luke.

+7
javascript jquery timeout loading
source share
2 answers

plain javascript

var loaded = false; var time = 30000; window.onload = function() { loaded = true; }; setTimeout(function() { if(!loaded) { window.location.reload(); } },time); 

JQuery

 var loaded = false; var time = 30000; $(function() { $(window).load(function() { loaded = true; }); setTimeout(function() { if(!loaded) { window.location.reload(); } },time); }); 
+13
source share

You can write this in your html header:

 <meta id="meta-refresh" http-equiv="refresh" content="30; URL=(your url)"> 

It refreshes the page after 30 seconds. There might be something like this in your jQuery part:

 $(window).load(function() { $("#meta-refresh").remove(); }); 
+4
source share

All Articles