How can I control the position of new browser windows created with the
window . open method?
In both scripting languages, the
window . open method takes the following form:
window . open (URLThe first parameter is the URL of the document to be displayed in the new window; the second parameter is the name of the new window (used for frame and window targets); and the third parameter is a quoted, comma-separated list of window features. (All three parameters are strings.)
left" and "
top," and they take the form
where hpixels and vpixels are the horizontal and vertical pixel coordinates of the upper-left corner of the new window.
Thus, if you want your JScript program to open a 400-by-200 pixel window in the upper-left corner of the users screen, you can do it on Internet Explorer with the following code:
Because Netscape Navigator simply ignores unrecognized features in the window features list, it is probably safe to use
window . open (location, name, "top=0,left=0,width=400,height=200");
topregardless of your "target browser audience." In fact, since there is a pretty good chance that future versions of Netscape will support these features, it probably won't hurt to begin using them now. Remember, however, that at present they only work on Internet Explorer.
30 Dec. 1996
Editor's note: Netscape Navigator 4 now includes support for window positioning. Use
screenX instead of