[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

help with javascript - centering a modal dialog

Posted on 2014-01-16
3
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
dimmergeek earned 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

649 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