Solved

help with javascript - centering a modal dialog

Posted on 2014-01-16
3
233 Views
Last Modified: 2014-01-17
I have this code that I use to center a modal dialog.    it used to work for IE and Firefox.  My harddrive crashed, and I had to reinstall my entire development environment.    Now, this code works for IE,  but not Firefox.  Any idea why?   Any better way to center a modal dialog?

       
var WIDTH = 850;
	var HEIGHT = 850;
		
	function ShowIncident(incident_id) {
 	
		var top = (screen.height / 2) - (HEIGHT / 2) ;
    	       var left = (screen.width / 2) - (WIDTH / 2);
								
		page = "../tds_incident/ShowTds_Incident.aspx?Tds_incident=" + incident_id
		mywindow = window.showModalDialog(page, null,
			"scroll:yes; resizable:no; help:no; " +
			"dialogTop:" + top + "px;" +
			"dialogLeft:" + left + "px; " +
			"dialogWidth:" + WIDTH + "px; " +
			"dialogHeight:" + HEIGHT + "px; ");
			
	}

Open in new window

0
Comment
Question by:HLRosenberger
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
dimmergeek earned 500 total points
ID: 39786896
Using '=' instead of ':' seems to help.

You can also add centerWindowOnScreen() after the window opens

var WIDTH = 850;
        var HEIGHT = 850;

        var top = (screen.height / 2) - (HEIGHT / 2);
        var left = (screen.width / 2) - (WIDTH / 2);

        var page = "http://www.experts-exchange.com";
        mywindow = window.showModalDialog(page, null, "scroll=yes, resizable=no, help=no, dialogTop=" + top + "px, dialogLeft=" + left + "px, dialogWidth=" + WIDTH + "px, dialogHeight=" + HEIGHT + "px");
        mywindow.centerWindowOnScreen();

Open in new window

0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 39789456
thanks.
0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39789527
Thank you!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question