繁体   English   中英

为什么这不会导致浏览器重定向?

[英]Why does this not cause a browser redirect?

if (selectedddItem.toString().indexOf("6ft with two") > -1) {
  window.location = "http://www.google.com/";
  alert("just passed over");
}

警报窗口将打开,因此条件为true ...但是浏览器不会重定向?!?!

有什么想法吗?

根据您使用的浏览器, window.location =可能还不够。

尝试使用window.location.href = "http://www.google.com"; “完全合格window.location.href = "http://www.google.com";

但是,该代码中的jQueryfication为零:-)

window.location.href

是您要寻找的

有这样的代码:

if (selectedddItem.toString().indexOf("6ft with two") > -1) {
  alert("just passed over");
  top.location.href = "http://www.google.com/";
}

确保在浏览器重定向之前先看到此警报,否则,如果条件返回false。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM