簡體   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