Modal and Modeless Dialog Boxes: Trusted Application's Windows - Doc JavaScript | WebReference

Modal and Modeless Dialog Boxes: Trusted Application's Windows - Doc JavaScript


Modal and Modeless Dialog Boxes

Trusted Application's Windows

The functions showModalDialog() and showModelessDialog() are tightly coupled to the concept of a "trusted application." Trusted applications are allowed actions that Internet Explorer would never approve of for Web pages. They do not bother the user with questions and interruptions, asking for their permission to run the application. They are fully trusted. Microsoft Visual Basic is a trusted application. So is an HTML Application (HTA). These applications are considered to be trusted because they use Internet Explorer interfaces to get inputs from the user, instead of the browser's standard input fields such as the Address bar. A dialog box opened by a trusted application is also trusted. To learn more about HTAs, go to Column 39, IE 5.0 Review, Part V: HTML Applications (HTAs).

Let's refresh your memory about what an HTA looks like. Pop up this simple HTA. When asked, choose "Open this file ..." instead of "Save this file to disk." The HTA window will pop up. Click the Go Away button.

The bar at the bottom edge of a window is referred to as the "status bar." By default, dialog boxes pop up with the status bar. Trusted applications, on the other hand, pop up without the status bar. Let's pop up a simple modeless dialog box. Now, pop up again the HTA. Click the Pop A Dialog Box button. You'll see that the dialog box does not display the status bar.

You can change the default behaviors of trusted and untrusted applications with respect to the status bar. Let's see an untrusted application without the status bar, accomplished by:

window.showModelessDialog('6.html','',
  'dialogLeft:10;status:no')

Let's force a trusted application to pop up a dialog box with the status bar. This HTA includes the following call:

window.showModalDialog('6.html','','status:yes');

Click the Pop A Dialog Box button. Observe the status bar at the bottom of the dialog box. The possible values of the status property are: yes, no, 1, 0, on, and off. Their semantics are intuitive.

Trusted applications are considered safe enough to remove the border window chrome from them. The border window chrome includes such important buttons as the close button. Once the border is gone, you won't have a way to close a dialog box. Therefore, make sure your dialog box has an alternative button to close it. This HTA includes the following call:

window.showModalDialog('6c.html','','unadorned:yes');

Click the bottom button. Observe the weird dialog box without any border (IE 5.5 and up). Click the Go Away button to close the dialog box. You cannot remove the border window chrome from a dialog box that opens from an untrusted application. Try it. We try to remove the border by:

window.showModelessDialog('6c.html','','unadorned:yes');

The possible values of the unadorned property are: yes, no, 1, 0, on, and off. Their semantics are intuitive.

The last property is dialogHide. It specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. We'll demonstrate this property in one of our upcoming columns on print templates.

Next: How to pass scalars and arrays to dialog boxes

http://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: August 13, 2001
Revised: August 13, 2001

URL: http://www.webreference.com/js/column90/6.html