homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

centering pop up windows

10+ Year Member

Msg#: 775 posted 10:13 pm on Mar 12, 2003 (gmt 0)

What can I add to this script to make the pop up window in IE and Netscape centered.

<SCRIPT LANGUAGE="Javascript">
var browser1 = navigator.appName;
if (browser1 == "Microsoft Internet Explorer"){
var newWin = window.open("features.htm", "method_desc", "status=no,width=755,height=480");
var newWin = window.open("nfeatures.htm", "method_desc", "status=no,width=755,height=480");



WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 775 posted 1:57 am on Mar 13, 2003 (gmt 0)

IE and Netscape use different variables in the window.open() method's feature string to position a new window. So you'll need to declare 4 variables: top= and left= for IE; screenX= and screenY= for Netscape. Now on to the calculations.

You can use screen.width to calculate left= and screenY= values with (screen.width-755)/2. A parallel approach would generate the vertical coordinates.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved