troubleshooting Question

Center a popup using JavaScript

Avatar of HLRosenberger
HLRosenbergerFlag for United States of America asked on
Web BrowsersJavaScript
22 Comments1 Solution1314 ViewsLast Modified:
I'm using showModalDialog.   I want to center the popup screen.  I'm doing this, which works fine using FireFox and Chrome:

width = 800; height = 500;
top = screen.height / 2 - (height / 2);
left = screen.width / 2 - (width / 2);

However, IE fails on screen.height (it does not fail on screen.width.. weird).

Any ideas on this?   Is there a workaround for screen.height using IE?  Or a more general way to center a popup?

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 22 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 1 Answer and 22 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