Helpful Information
 
 
Category: HTML & CSS
center the window horizontally

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>

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>

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.










privacy (GDPR)