EZE Posted January 19, 2007 Share Posted January 19, 2007 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 More sharing options...
EZE Posted January 20, 2007 Author Share Posted January 20, 2007 *bump* Link to comment https://forums.phpfreaks.com/topic/34930-centered-pop-up-function/#findComment-164911 Share on other sites More sharing options...
Jtech Posted January 21, 2007 Share Posted January 21, 2007 Rather specifie the width and height in the anchor ... specifie it in the script. Link to comment https://forums.phpfreaks.com/topic/34930-centered-pop-up-function/#findComment-165667 Share on other sites More sharing options...
Jtech Posted January 21, 2007 Share Posted January 21, 2007 Nope .. dont do what i said .. i tryed your script out and it work just fine so ...so ;) Link to comment https://forums.phpfreaks.com/topic/34930-centered-pop-up-function/#findComment-165675 Share on other sites More sharing options...
EZE Posted January 22, 2007 Author Share Posted January 22, 2007 Okay, I changed document to screen, so it works now. Problem Solved. Link to comment https://forums.phpfreaks.com/topic/34930-centered-pop-up-function/#findComment-166139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.