我正在使用Jquery Ajax登录表单。在ajax成功之后,我使用window.location.href="test.php"
重定向页面
这在Chrome,Firefox和IE9中运行良好。但在IE 11中,它无效。
我试过了,
window.location.replace("test.php");
window.location.assign("test.php");
setTimeout('window.navigate("test.php");', 1);
window.open('test.php','_self', null , false);
但都失败了。任何人都可以帮忙吗?
答案 0 :(得分:5)
尝试添加前导斜杠:
window.location.assign('/test.php');
<强>解释强>
每当设置位置时,它与单击同一页面上的超链接非常相似。所以,让我们说你在这样的位置:
...然后您尝试使用以下任何机制离开此页面,而不使用前导斜杠:
<a href="test.php">Test Page</a>
window.location = "test.php";
window.location.href = "test.php";
window.location.assign("test.php");
window.location.replace("test.php");
window.history.pushState("Test Page", {}, "test.php");
...您会注意到网址变为:
但是如果你设置一个前导斜杠 /test.php ,那么该位置就变成了这个:
答案 1 :(得分:4)
关于会话存储,您必须进行如下设置,
转到“工具” - >“网络选项”并单击“隐私”选项卡,然后选择“高级”,在该窗口中,选中“覆盖自动Cookie处理”和“始终允许会话Cookie”复选框。
它会起作用。对我来说很好。
的问候,
雷卡
答案 2 :(得分:0)
您可以使用document.location
代替它,按照this answer在IE11中使用。
document.location.href = "test.php";
答案 3 :(得分:0)
我这样解决了这个问题:
window.location.replace("test.php");
我建议使用location.assign("url")
或location.replace("url")
而不是location.href = url
。