Jquery:设置页面加载超时

发布于 2024-09-19 11:33:54 字数 143 浏览 3 评论 0原文

我想制作一个脚本来检测页面是否在 30 内完全加载,或者使用 Firefox 的方法(CTRL + F5)刷新页面,清除该页面的缓存并刷新。 可以制作吗? PS:如果不可能在 Jquery 中制作,我可以使用普通的 javascript。 提前致谢。 亲切的问候。 卢卡.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听你说爱我 2024-09-26 11:33:54

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

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);
});
流星番茄 2024-09-26 11:33:54

你可以在你的 html head 中写下:

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

30 秒后刷新页面。
在你的 jQuery 部分可能有这样的东西:

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

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();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文