[英]window.open does not work correctly in IE
我對 IE(測試版本 6 和 8)問題有很大的疑問。 Window.open 方法在 FF、Opera、Chrome 中正常工作。 IE 打開新的 window,但在主 window 中加載相同的 url。 我知道一種解決方案是從href中刪除url,但我需要它來關閉JS。 我還需要定位新的 window。
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>
請幫助我,這對我來說非常重要。 非常感謝!
您可以使用此解決方法來修復它。 先開一個空白的新window,移動它,然后改變位置。 它似乎與 IE 安全問題有關:
錨標簽:
<a class="ibm-b1-bttn" href="#" onclick="regForm();">Register Now</a>
JS Function:
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";
}
您可以嘗試在沒有 HTTP 的情況下引用 URL 嗎? 所以somepage.html
或\somepage.html
取決於文件在您的服務器上的位置?
解開 windows function 調用,看看它實際上給你的是哪一個錯誤:
var myWin = window.open("http://somepage.html", "Signin", "width=550,height=600,scrollbars=1");
myWin.moveTo(left, top);
window.open 不應該給你這個錯誤。 我敢打賭這是moveTo?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.