spacer
Yehuda Shiran August 18, 2001
The Dialog Box's Position
Tips: August 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

By default, a dialog box is centered within the desktop. This is the default of the center property. Notice where the window opens when center is set to no. The possible values of the center property are: yes, no, 1, 0, on, and off. Their semantics are intuitive. This is how we turned off centering of the above window:

window.showModalDialog('010818.html','',
  'dialogHeight:200px;dialogWidth:800px;center:no');
The window opens close to the upper-left corner of the desktop. You can control the specific location of the window with the dialogLeft and dialogTop parameters. Let's position our window 300 pixels and 500 pixels to left and top, respectively, of the upper-left corner of the desktop:

window.showModalDialog('010818.html','',
  'dialogHeight:200px;dialogWidth:800px;dialogLeft:300;
   dialogTop:500');
Even if you do center the window, its position specifications (dialogLeft and dialogTop) override the centering request. Try it:

window.showModalDialog('010818.html','',
  'dialogHeight:200px;dialogWidth:800px;dialogLeft:300;
  dialogTop:500';center:yes);
For more on modal and modeless dialog boxes, go to Column 90, Modal and Modeless Dialog Boxes.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business