开发者

Why does this not cause a browser redirect?

开发者 https://www.devze.com 2023-02-17 22:20 出处:网络
if (selectedddItem.toString().indexOf(\"6ft with two\") > -1) { window.location = \"http://www.google.com/开发者_运维技巧\";
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?


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 :-)


window.location.href

Is what you are looking for


Have your code like this:

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

Make sure you are seeing this alert first before browser redirect otherwise your if condition is returning false.

0

精彩评论

暂无评论...
验证码 换一张
取 消