views:

82

answers:

2

Hi to all, i would like make a script that detect if the page is full loading in 30 or else refresh the page with method (CTRL + F5) of Firefox that clear the cache of that page and refresh.. Is possibile to make? P.S: If is not possibile to make in Jquery i can use normal javascript. Thanks in advance. Kind Regards. Luca.

+5  A: 

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);
});
Ninja Dude
You can also use `window.location.reload()`.
BalusC
Thanks you,work perfectly :)
Luca
A: 

You can write this in your html head:

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

It refreshes the page after 30 seconds. In your jQuery part there could be something like this:

$(window).load(function() {
  $("#meta-refresh").remove();
});
elektronikLexikon
Thanks you too,but i was need a function to add in a external script and in a page :-( Thanks you anyway ;-)
Luca