window.location.href在IE 11中不起作用

我正在使用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); 

但都失败了。任何人都可以帮忙吗?

尝试添加前导斜杠:

 window.location.assign('/https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php'); 

说明
每当设置位置时,它的工作方式与单击同一页面上的超链接非常相​​似。 所以,假设你在这样的位置:

http://yourdomain.com/this/is/a/very/long/path.php

…然后您尝试使用以下任何机制离开此页面而不使用前导斜杠

 Test Page window.location = "https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php"; window.location.href = "https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php"; window.location.assign("https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php"); window.location.replace("https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php"); window.history.pushState("Test Page", {}, "https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php"); 

…你会注意到URL变为:

http://yourdomain.com/this/is/a/very/long/path.php

但是如果你设置一个前导斜杠/https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php ,那么该位置就变成了:

http://yourdomain.com/https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php

关于会话存储,您必须进行如下设置,

转到“工具” – >“Internet选项”,然后单击“隐私”选项卡,选择“高级”,在该窗口中,选中“覆盖自动Cookie处理”和“始终允许会话cookie”复选框。

它会起作用。对我很好。

问候,
雷卡

您可以使用document.location ,它可以在IE11中按照此答案工作 。

 document.location.href = "https://stackoverflow.com/questions/28872598/window-location-href-not-working-in-ie-11/test.php";