问题描述
限时送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;IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论