[thelist] centering a popup window.....

Anthony Baratta Anthony at Baratta.com
Wed Jan 31 18:22:48 CST 2001


We are developing a site that has a user login component and have decided 
that the login screen will be a pop box. The following Javascript works 
great in Netscape, but does not work correctly in IE.

<SCRIPT language=JavaScript>
function Login() {
     var x = 0;
     var y = 0;
     var width = 110;
     var height = 170;
     theURL = "http://www.foo.com/login_popup.asp";
     winName = "fb_signin";
     x = (screen.availWidth - 12 - width) / 2;
     y = (screen.availHeight - 48 - height) / 2;
     winFeatures = "status=0,scrollbars=0,resizable=0,screenX=" + x + 
",screenY=" + y + ",width=" + width + ",height=" + height;
// -->

[NOTE: The fudging of the x and y coordinates helps to center the popup box 
based upon the size of the popup box. I "learned" this code from ESPN.com.]

When we click on the following link,

<a href="javascript:Login();">blah</a>

Netscape "centers" the popup box as designed. IE does not. Both report that 
the X and Y coordinates are the same.

Any clues or wacks up side the head are appreciated.
Anthony Baratta
Keyboard Jockeys

More information about the thelist mailing list