...

View Full Version : center the window horizontally



cunning-fox
06-18-2002, 03:07 AM
Hi,

Is there anything you can add to this code to make the window centered horizontally and vertically. Here is the code:

<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>


<a href="#" onClick="MM_openBrWindow(page.html,'','scrollbars=no,width=551,height=324,directories=no,menubar=no,resizable =yes,left=121,top=100')">Click Here</a>

x_goose_x
06-18-2002, 03:56 AM
Didn't test it, because pop ups don't work on my pc, but I think it should work and here it is.

<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
pop = window.open(theURL,winName,features);
if (document.layers) {
xoff = (screen.availWidth-pop.window.outerwidth)/2;
yoff = (screen.availHeight-pop.window.outerheight)/2;
}else if (document.all) {
xoff = (screen.width-pop.document.body.scrollWidth)/2;
yoff = (screen.height-pop.document.body.scrollHeight)/2;
}
pop.moveTo(xoff,yoff);
}
//-->
</script>

eak
06-18-2002, 06:30 AM
go to my NewWindow script generator (http://www.eak.homeip.net/portfolio/newwindowgen.php) to get the javascript that will do exactly what you want.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum