 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
glala
Joined: 06 Jan 2005 Posts: 1
|
Posted: Thu Jan 06, 2005 3:18 pm Centering a popup on open of webpage |
|
|
|
I can't seem to find the code to center a popup instead of specifically specifying it's location or letting it open in the default location. Can someone please provide me with the parameter?
Many thanks,
Glenn |
|
chrisxkelley
Joined: 07 Dec 2004 Posts: 246
|
Posted: Thu Jan 06, 2005 4:50 pm |
|
|
|
here is a script that goes by the total window size, divides it by two, then opens the popup in that location. else, it opens it in the center of a 1024x768 screen.
just stick in your parameters at the bottom, put this code in your page, and use centerWindow(); to call your function
| Code: |
<script language="JavaScript"><!--
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 = 1024, yMax=768;
var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
window.open('testpage.htm','myExample7',
'width=200,height=200,screenX='+xOffset+',screenY='+yOffset+',
top='+yOffset+',left='+xOffset+'');
}
centerWindow();
//--></script>
|
hope this helps
cheers,
chris |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|