2011-05-31 261 views
0

我有一個與IE(測試版本6 & 8)問題很大的問題。 Window.open方法在FF,Opera,Chrome中正常工作。 IE打開新窗口,但在主窗口中加載相同的URL。 我知道一個解決方案可以從href中刪除url,但我需要它爲JS關閉案件。另外我需要爲新窗口定位。window.open在IE中無法正常工作

IE「錯誤控制檯」說:訪問被拒絕。

<script type="text/javascript"> 
function regForm() 
{ 
var left = Math.abs((window.innerWidth - 550)/2); 
var top = Math.abs((window.innerHeight - 600)/2); 
window.open("http://somepage.html", "Signin", "width=550,height=600,scrollbars=1").moveTo(left, top); 
}   
</script> 
<a class="ibm-b1-bttn" href="http://somepage.html" onclick="javascript:regForm(); return false;">Register Now</a> 

請幫助我,這對我很重要。非常感謝!

+0

你試圖消除'的moveTo()'? - 我懷疑這比'window.open()'本身更可能是問題。 – Spudley 2011-05-31 15:52:54

+0

問題不在於window.open(),它與事件處理程序的工作方式一致。 – Pointy 2011-05-31 15:55:52

+0

您是否嘗試過更改'',以便它的「href」值只是「#」? – Pointy 2011-05-31 15:56:48

回答

0

你可以嘗試引用沒有HTTP的URL嗎?所以somepage.html\somepage.html取決於文件駐留在您的服務器上的位置?

+0

這不會幫助,我不認爲。 – Pointy 2011-05-31 15:56:01

0

unchain的窗函數調用,看看哪一個它實際上是給你的錯誤:

var myWin = window.open("http://somepage.html", "Signin", "width=550,height=600,scrollbars=1"); 
myWin.moveTo(left, top); 

window.open不應該放棄這樣的錯誤。我打賭這是移動?

0

您可以使用此解決方法來修復它。首先打開一個空白的新窗口,移動它,然後改變位置。它似乎是與IE瀏覽器的安全問題:

錨標籤:

<a class="ibm-b1-bttn" href="#" onclick="regForm();">Register Now</a> 

JS功能:

function regForm() { 
     var left = Math.abs((window.innerWidth - 550)/2); 
     var top = Math.abs((window.innerHeight - 600)/2); 
     var win = window.open("", "Signin", "width=550,height=600,scrollbars=1") 
     win.moveTo(left, top); 
     win.location = "http://somepage.html"; 
    } 
相關問題