开发者

javascript window.open not the requested size in chrome

When opening a popup window in chrome, its not the requested size the majority of the time. Seems the first time I open the window its the correct size, but if I close it and open it again, its all whacked out of shape.

Is there some开发者_JS百科thing special i need to do with chrome?


Stumbled across this , might be good for you:

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()}
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜