2011-06-09 105 views
1

我有這個簡單的代碼,在每個瀏覽器中工作正常,但不在IE中(每個版本)。window.location在IE中的問題

window.setTimeout('window.location = \"http://www.domain/modules/yobilab/copyright/classes/GO_overview.php?refNumb=".$RefNumb."\"', 3000); 
      return false; 

在每一個瀏覽器,它會去到正確的鏈接

在IE瀏覽器,而不是它也包括來自何方的鏈接,所以它會成爲這樣的事情:

http://www.domain/PAGEWHEREIWAS/modules/yobilab/copyright/classes/GO_overview.php?refNumb=something 

爲什麼它是這樣做的?

它顯然會產生NOT FOUND錯誤。

+1

對我來說看起來並不「簡單」。究竟是什麼'\「http://www.domain/modules/yobilab/copyright/classes/GO_overview.php?refNumb =」。$ RefNumb。「\」'在JavaScript中的意思是? – 2011-06-09 18:13:59

+0

對不起,也是PHP的組合。只需看看javascript代碼,並忘記PHP – 2011-06-09 18:15:14

+1

號碼摘要PHP完全沒有問題,以便我們確信它不會導致您的問題。並在[jsfiddle.net](http://jsfiddle.net)上提供一個演示該問題的實況測試用例。 – 2011-06-09 18:15:51

回答

10

嘗試使用document.location而不是window.location

+0

這解決了這個問題..我會在4分鐘內接受你的答案= D謝謝大家的幫助! – 2011-06-09 18:22:12

3

你需要創建一個匿名函數:

setTimeout(function() {window.location = "http://www.domain/modules/yobilab/copyright/classes/GO_overview.php?refNumb=12"}, 3000); 
+0

document.location不適用於我,這一個! – neolei 2012-05-08 02:00:57

+0

它實際上做了什麼? – divHelper11 2016-08-04 18:13:47

0
function redirect() { 
    window.location.href = "http://www.domain/PAGEWHEREIWAS/modules/yobilab/copyright/classes/GO_overview.phprefNumb=something"; 

} 

setTimeout(redirect, 3000); 
1

添加一個「/」鏈接之前,這使得IE明白,這是一個相對鏈接,並迫使正確的重定向。