Have you been wondering how to pop-up a new window in the center of the browser screen the way
you desire. To actually center the pop up window, you need the use of the window objects outer
width, and outer height property and screen object width and height property. Use the following
code.
Function centerWindow() { if (document.all) { var xMax = screen.width, yMax = screen.height } else if (document.layers) { var xMax = window.outerWidth, yMax = window.outerHeight } else { var xMax = 640, yMax=480 } var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2; window.open('testpage.htm','Example','width=200,height=200,screenX='+x Offset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'') }
This was first published in June 2001