window.location IE中的问题

时间:2011-06-09 18:10:52

标签: javascript internet-explorer

我有这个简单的代码,可以在每个浏览器中正常工作,但不在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错误。

4 个答案:

答案 0 :(得分:11)

尝试使用document.location代替window.location

答案 1 :(得分:3)

您需要创建一个匿名函数:

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

答案 2 :(得分:1)

添加" /"在链接之前,这使IE了解它是一个相对链接并强制正确的重定向。

答案 3 :(得分:0)

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

}

setTimeout(redirect, 3000);
相关问题