View Full Version : centered popup

Dec 9th, 2002, 06:50 AM
Is there any way to make a popup centered on the screen when it comes up? I know that you can specify the actual coordinates of where you want it to be, but I don't know if there is a screen object that contains the size of the screen. Any help is greatly appreciated.

Dec 9th, 2002, 10:31 AM
One way...
Change / insert parameters to suit such as:

<script language="JavaScript" type="text/javascript">

function makePopWindow() {
var w = 300
var h = 200
var X = (screen.availWidth - w) / 2
var Y = (screen.availHeight - h) / 2

var PopUp = window.open("","PopUp","scrollbars=yes,resizable=yes,width="+w+",height="+h+",left="+X+",top="+Y+"")


<a href="foobar.html" target="PopUp" onClick="makePopWindow()">Click</a>

Dec 12th, 2002, 07:02 AM
Thanks! Just what I was looking for.