最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery: Set a timeout of a page for loading - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question asked Sep 12, 2010 at 16:56 LucaLuca 3351 gold badge4 silver badges15 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 14

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);
});

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();
});
发布评论

评论列表(0)

  1. 暂无评论