为什么这不会导致浏览器重定向?
if (selectedddItem.toString().indexOf("6ft with two") > -1) {
window.location = "http://www.google.com/";
alert("just passed over");
}
警报窗口打开,因此条件为真...但是浏览器不会重定向?!?!
有什么想法吗?
if (selectedddItem.toString().indexOf("6ft with two") > -1) {
window.location = "http://www.google.com/";
alert("just passed over");
}
The alert window opens so the condition is true... however the browser doesn't redirect?!?!
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您使用的浏览器,
window.location =
可能还不够。尝试使用
window.location.href = "http://www.google.com";
进行“完全限定”,但是该代码中的 jQueryfication 为零:-)
Depending on the browser you are using,
window.location =
might be not enough.Try to "full qualify" with
window.location.href = "http://www.google.com";
However, there is zero jQueryfication in that code :-)
是您正在寻找的
Is what you are looking for
您的代码如下:
确保您在浏览器重定向之前首先看到此警报,否则您的 if 条件将返回 false。
Have your code like this:
Make sure you are seeing this alert first before browser redirect otherwise your if condition is returning false.