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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.