Pad*_*ddy 8 javascript internet-explorer
我的页面上有一个处理会话超时的脚本,当会话到期时在客户端重定向用户.完整的代码有点复杂,但我已经将代码修改为导致我问题的原因:
<head runat="server">
<script src="javascript/jquery-1.7.2.min.js" type="text/javascript">
</script>
<script type="text/javascript">
/*
Please see document ready method at the bottom that sets
up this code, calling CheckActivity() at intervals.
*/
var warningInterval, redirectTimeout;
var now = 1;
function TimeoutRedirect() {
window.location.href = "Test2.aspx";
}
//In this example this is a bit of a null op, but in real
//code this will display a warning a minute or so prior to redirect.
//This is required to recreate...
function CheckActivity() {
if (now > 4) {
clearInterval(warningInterval);
redirectTimeout = setTimeout(function () {
TimeoutRedirect(); }, 5000);
}
//Some visual activity for testing purposes.
$("#CheckActivityCount").text(now);
now++;
}
$(document).ready(function () {
warningInterval = setInterval(function () {
CheckActivity(); }, 1000);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="CheckActivityCount">
</div>
</div>
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
此代码按预期工作,在(大约)十秒后重定向.但是,如果间隔调用CheckActivity完成后(5秒后),我锁定我的屏幕,然后在重定向发生后再解锁(另外5秒),我的IE窗口中的URL已经转到'test2 .aspx',但窗口似乎已冻结(仍显示第一页).
这最终不会冻结,但到达下一页需要10秒钟.
这似乎只发生在IE(在我的机器上的IE9),并在Chrome和Firefox(和奇怪的IE6)中很好.
(Test2.aspx是一个非常简单的页面,只包含文本'success'.)
只是注意到如果我将重定向从test.aspx更改为http://www.google.com/,这似乎不是问题.但是,如果我将test2.aspx更改为绝对URL(唯一的主要区别是这将是本地主机地址)仍然无效.