Tim’s
Bandwagon

Javascript window.open sizes not reliable?

In Safari, why are windows opened via Javascript 2 pixels wider and 1 pixel higher than requested?

I googled for the answer no avail, so made a simple test page, and asked for answers on a (usually quite reliable) local mailing list, but haven’t got an answer. So, I posted the test page to my linklog in the hope of it gaining a wider audience. A few hits, but no answer :-( .

So: now, I’m re-posting the question here to drizzle a little google-juice on the test page, and hope one of my legion of trusty feed subscribers can spring to my assistance.

I suppose a keyword-stuffed rephrasing of the question could be: Is there reliable cross browser way or technique for opening a fixed-size window via Javascript or with DOM browser scripting (window.open or similar)?

6 Comments

  1. Just found this uber-test page for javascript popup windows.

  2. An update: since this article was posted, Safari has been updated. (The most current version at the time of posting was Safari 1.2.4 [v125.12]). The new version (1.3 for Mac OS 10.3.9) fares much better, giving the correct width, but still not the right height (it seems to be 1 pixel shorter than requested).

  3. In Safari 2.0 (Under tiger) the width seems to be fine in your test page, but the height opens 1 pixel short. First too long… now to short ?!? What the hell Apple. I seem to be having trouble with Javasscript all over the place. Google Maps no longer works at all.

  4. Hi,

    I had exactly the seem problem (sort of) Safari and FF on mac both do seem to have this problem. I fixed the wrong size by resizing them within the popup window itself by using some of the cross-browser xLibrary and the following lines of code:

    window.resizeBy(950-xWidth(document),665-xHeight(document))

  5. Some of my previous remarks were left out, but check this website for xWidth and xHeight: http://www.cross-browser.com/

  6. I googled this post and thought I would add this new comment.

    Having a similar problem with IE 7.0 after upgrading. IE now makes my popups wider than specified by the window.open() stuff. Very annoying! I googled everywhere, and no good info. For my 215px wide, 270px high popup, IE adds 35px’s to the width. Maybe I’m doing something wrong, but they worked before in all browsers and now only IE screws them up!

    If you know a fix, post anywhere and I will eventually find it.

Leave a Comment

Your personal information

Your comment