window.location.href 无法在 IE 11 中运行
window.location.href not working in IE 11
我正在使用 Jquery Ajax 登录 form.After ajax 成功,我使用 window.location.href="test.php"
重定向页面
这在 Chrome、firefox 中工作正常,在 IE 11 中的 IE9.But 中也工作正常,但它不工作。
我试过了,
window.location.replace("test.php");
window.location.assign("test.php");
setTimeout('window.navigate("test.php");', 1);
window.open('test.php','_self', null , false);
但是所有fails.Can有人帮忙吗?
尝试添加前导斜杠:
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");
...你会注意到 URL 变成了这个:
但是如果你在前面加上斜线,/test.php,那么位置就变成了这样:
您可以改用 document.location
,它在 IE11 中按照 this answer 运行。
document.location.href = "test.php";
关于session存储,你要进行如下设置,
转到“工具”->“Internet 选项”并单击“隐私”选项卡和“select 高级”,然后在 window 中选中“覆盖自动 Cookie 处理”框和“始终允许会话 cookie”复选框。
它 work.It 适合我。
此致,
雷卡
我是这样解决这个问题的:
window.location.replace("test.php");
我会推荐 location.assign("url")
或 location.replace("url")
而不是 location.href = url
。
我正在使用 Jquery Ajax 登录 form.After ajax 成功,我使用 window.location.href="test.php"
这在 Chrome、firefox 中工作正常,在 IE 11 中的 IE9.But 中也工作正常,但它不工作。
我试过了,
window.location.replace("test.php");
window.location.assign("test.php");
setTimeout('window.navigate("test.php");', 1);
window.open('test.php','_self', null , false);
但是所有fails.Can有人帮忙吗?
尝试添加前导斜杠:
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");
...你会注意到 URL 变成了这个:
但是如果你在前面加上斜线,/test.php,那么位置就变成了这样:
您可以改用 document.location
,它在 IE11 中按照 this answer 运行。
document.location.href = "test.php";
关于session存储,你要进行如下设置,
转到“工具”->“Internet 选项”并单击“隐私”选项卡和“select 高级”,然后在 window 中选中“覆盖自动 Cookie 处理”框和“始终允许会话 cookie”复选框。
它 work.It 适合我。
此致,
雷卡
我是这样解决这个问题的:
window.location.replace("test.php");
我会推荐 location.assign("url")
或 location.replace("url")
而不是 location.href = url
。