PDA

View Full Version : centered popup



blademan83
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.

PauletteB
Dec 9th, 2002, 10:31 AM
One way...
Change / insert parameters to suit such as:
menubar=yes,toolbar=no,location=yes,status=yes,
scrollbars=yes,resizable=yes,directories=yes

<body>
<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+"")
}

</script>

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

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