troubleshooting Question

Center a Pop-Up Window

Avatar of jonnyz0109
jonnyz0109 asked on
Internet MarketingJavaScript
9 Comments2 Solutions2657 ViewsLast Modified:
Hopefully this should be a simple one!  My current code:

<script language="JavaScript">
<!-- hide

function openPopup() {
  popupWin = window.open('enrollment_request.htm','open_window','status,dependent,width=450,height=315,left=0,top=0')
}
// Default (to show available options) below:
// popupWin = window.open('http://webdesign.about.com/','open_window','menubar,toolbar,location,directories,status,scrollbars,resizable,dependent,width=640,height=480,left=0,top=0')

// done hiding -->

</script>

<a href="javascript:openPopup();">here</a>


First, is this code a good balance between compatibility and simplicity?  I am coding this at work and need to make it simple enough for future people to edit the page without any scripting background.

Second, I want to center the window, both height and width, according to the the resolution of the user's computer.  If the res. was set to 800 x 600, the left side of the window would pop at ( 800 - 450 ) / 2 = 175 and the top would pop at ( 600 - 315 ) / 2 = 142.5 (or 143)... but also if the user's resolution was 1024 x 768 it'd evaluate that and do left side at ( 1024 - 450 ) / 2 = 287 and top side at ( 768 - 315 ) / 2 = 226.5.

Thanks in advance!
ASKER CERTIFIED SOLUTION
cubrovic

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros