setInterval &IE浏览器

编程入门 行业动态 更新时间:2024-10-27 10:27:25
本文介绍了setInterval &IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我上下搜索过,但还没有找到可以让 setInterval 在任何版本的 Internet Explorer 中工作的东西.

下面是我现在使用的代码...

<div id="varRefresh">

谁能指出我正确的方向,以便我可以在 IE 中使用它?

解决方案

您尝试加载的页面可能只是被缓存了.

您可以强制 Internet Explorer 不缓存页面,如下所示:防止缓存 Internet Explorer 8 中的页面.

或者,您可以简单地将时间戳附加到 URL;因为这个 URL 对 IE 来说是新的,所以它总是会加载最新版本.

示例:

$(document).ready(function () {$('#varRefresh').load('reload.php?'+new Date().getTime());window.setInterval(refreshVar, 5000);//**** 每 5 秒});函数 refreshVar() {$('#varRefresh').load('reload.php?'+new Date().getTime());}

I have searched up and down and have yet to find something that will allow setInterval to work in any version of Internet Explorer.

Below is the code I am using right now...

<script type="text/javascript">

$(document).ready(function () {
    $('#varRefresh').load('reload.php');

    window.setInterval("refreshVar();", 5000); //**** every 5 seconds
});

function refreshVar() {
    $('#varRefresh').load('reload.php');
}
</script>

<div id="varRefresh">
</div>

Can anyone point me in the right direction so I can get it to work in IE?

解决方案

The page you're trying to load may simply be cached.

You can force Internet Explorer not to cache pages as follows: Prevent caching of pages in Internet Explorer 8.

Alternatively, you may simply append a timestamp to the URL; because the URL is new to IE, it will always load the latest version.

Example:

$(document).ready(function () {
    $('#varRefresh').load('reload.php?'+new Date().getTime());

    window.setInterval(refreshVar, 5000); //**** every 5 seconds
});

function refreshVar() {
    $('#varRefresh').load('reload.php?'+new Date().getTime());
}

这篇关于setInterval &amp;amp;IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 08:38:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1038441.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:浏览器   setInterval   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!