setInterval& IE浏览器 [英] setInterval & Internet Explorer

查看:182
本文介绍了setInterval& IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>

谁能指出我正确的方向,以便我可以在IE中正常工作?

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.

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

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

或者,您可以简单地在URL上附加时间戳;由于该URL是IE的新功能,因此它将始终加载最新版本.

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

$(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆