Jump to content

Centered Pop Up Function


EZE

Recommended Posts

Okay, I have been trying to write a pop-up function for javascript that is centered, and specifies the width, height, and url in the function. Everything in the script i made is correct and working, except the yPosition variable. The xPosition variable is outputting correctly though. Here is my script:
[code]<script type="text/javascript">
function OpenWindow(url, w, h)
{
var xPosition = ((document.width-w)/2);
var yPosition = ((document.height-h)/2);
window.open("" + url + "", "contentwin","width=" + w + ",height=" + h + ",scrollbars=no,status=no,resizable=no,screenX=" + xPosition + ",screenY=" + yPosition + "");
}
</script>
<a href="#" onclick="OpenWindow('http://phpfreaks.com/',450,500);">Click</a>[/code]
What can i do to fix this? I am trying to use this type of pop up function, not a pre-written one, so if anybody could help me debug this script, it would be awesome.
Link to comment
https://forums.phpfreaks.com/topic/34930-centered-pop-up-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.