我使用window.open()打開window.open出現在webkit瀏覽器後面,但是如果我打開Facebook或Twitter頁面,則不會。
http://twitter.com/share ..和 http://www.facebook.com/sharer.php ...
,允許用戶發佈自己的Facebook或Twitter帳戶。
這些彈出窗口正確顯示在我當前的Chrome或Safari窗口的正面。
但是,當我將URL更改爲當前域中的另一個頁面時,彈出窗口顯示在當前窗口的後面,而不是infront!?相同的代碼,打開窗口的相同函數,只是傳遞給window.open()的一個不同的URL。
我弄不明白爲什麼,我試過了一切,在彈出的頁面中註釋掉任何javascript或任何可能導致Chrome/Safari認爲它是惡意的。
這些瀏覽器是否將URL檢測爲Facebook/Twitter並允許它出現在前面,並將其他東西推到後面?
這是我打開窗戶
InfoOverlay.prototype.popupWindow = function(url, title, width, height)
{
var left = (screen.width/2) - (width/2);
var top = (screen.height/2) - (height/2);
var targetWin = window.open(
url,
title,
'toolbar=no, location=no, directories=no, alwaysRaised=yes, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left
);
// These 2 lines added on suggestion from commenter below
// (doesn't fix issue)
targetWin.blur();
targetWin.focus();
}
使用'window.foucs()' – anu