5

在 chrome 中打开弹出窗口时,大多数情况下它不是请求的大小。似乎我第一次打开窗户时它的尺寸是正确的,但如果我关闭它并再次打开它,它就会完全变形。

我需要用 chrome 做些什么特别的事情吗?

4

2 回答 2

0

Have you named your popup window? I'm guessing Chrome has some logic to remember windows that it has already opened and it sounds like this might be interfering with your popups, hence it working correctly the first time. I'd suggest giving not naming the popup window a try.

于 2013-05-17T15:50:59.390 回答
0

偶然发现这个,可能对你有好处:

http://roneiv.wordpress.com/2008/01/18/open-a-popup-window-in-javascript-with-windowopen-crossbrowser-solution/

var myPopupWindow = '';
function openPopupWindow(url, name, width, height)
{
    //Remove special characters from name
    name = name.replace(/\/|\-|\./gi, "");

    //Remove whitespaces from name
    var whitespace = new RegExp("\\s","g");
    name = name.replace(whitespace,"");

    //If it is already open
    if (!myPopupWindow.closed && myPopupWindow.location)
    {
        myPopupWindow.location.href = encodeUrl(url);
    }
    else
    {
        myPopupWindow= window.open(encodeUrl(url),name, "location=no, scrollbars=yes, resizable=yes, toolbar=no, menubar=no, width=" + width + ", height=" + height );
        if (!myPopupWindow.opener) myPopupWindow.opener = self;
    }

     //If my main window has focus - set it to the popup
    if (window.focus) {myPopupWindow.focus()}
}
于 2013-02-05T08:12:38.950 回答