August 18, 2001 - The Dialog Box's Position | WebReference

August 18, 2001 - The Dialog Box's Position

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

Yehuda Shiran, Ph.D.
Doc JavaScript

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.