How to Use showModelessDialog () _ basic knowledge

Source: Internet
Author: User
ShowModelessDialog () has many built-in methods to generate a dialog box, such as window. alert (), window. confirm (), window. prompt. However, IE provides more methods to support the dialog box. For example:
ShowModalDialog () (IE 4 + supported)
ShowModelessDialog () (IE 5 + supported)

The window. showModalDialog () method is used to create a modal dialog box that displays HTML content. Because it is a dialog box, it does not have all the properties of the window opened by window. open.

The window. showModelessDialog () method is used to create a non-modal dialog box that displays HTML content.

When we use showModelessDialog () to open a window, we do not need to use a window. close () to close it. When it is opened in non-modal mode [IE5], other operations can still be performed in the window that opens the dialog box, that is, the dialog box is not always the top focus, it is automatically closed when the window URL is changed. The mode [IE4] Dialog Box always has focus (Focus cannot be removed until it is closed ). The modal dialog box is associated with the window that opens it. Therefore, when we open another window, their links are still saved and hidden under the activity window.

The usage is as follows:
VReturnValue = window. showModalDialog (sURL [, vArguments] [, sFeatures])
VReturnValue = window. showModelessDialog (sURL [, vArguments] [, sFeatures])

Parameter description:
SURL
Required parameter. Type: string. Specifies the URL of the document to be displayed in the dialog box.
VArguments
Optional parameter; Type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays. The dialog box uses window. dialogArguments to obtain the passed parameters.
SFeatures
Optional parameter; Type: String. Used to describe the appearance and other information of the dialog box. You can use one or more of the following, separated by semicolons.
In the dialogHeight dialog box, the height is not smaller than px. In IE4, the default unit of dialogHeight and dialogWidth is em, while in IE5, the default unit is px. For convenience, When you define the modal mode dialog box, unit with px.
DialogWidth: Dialog Box width.
DialogLeft: The left distance from the desktop.
DialogTop: the distance from the desktop.
Center: {yes | no | 1 | 0}: whether the window is centered. The default value is yes, but the height and width can still be specified.
Help: {yes | no | 1 | 0}: whether to display the help button. The default value is yes.
Resizable: {yes | no | 1 | 0} [IE5 +]: whether the size can be changed. No by default.
Status: {yes | no | 1 | 0} [IE5 +]: whether to display the status bar. The default value is yes [Modeless] or no [Modal].
Scroll: {yes | no | 1 | 0 | on | off}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.

There are also several attributes used in HTA, which are generally not used in general web pages.
DialogHide: {yes | no | 1 | 0 | on | off}: whether the dialog box is hidden when printing or previewing. The default value is no.
Edge: {sunken | raised}: Specifies the border style of the dialog box. The default value is raised.
Unadorned: {yes | no | 1 | 0 | on | off}: no by default.

Input parameters:
VArguments is used to pass Parameters in the dialog box. The type is not limited. For string types, the maximum value is 4096 characters. Objects can also be passed, for example:

Test1.htm
Script
Var mxh1 = new Array ("mxh", "net_lover", "Chapter E of Mencius ")
Var mxh2 = window. open ("about: blank", "window_mxh ")
// Pass the array to the dialog box
Window. showModalDialog ("test2.htm", mxh1)
// Pass the window object to the dialog box
Window. showModalDialog ("test3.htm", mxh2)
Using script‑test2.htm
Script
Var a = window. dialogArguments
Alert ("the parameter you passed is:" +)
Script
Test3.htm
Script
Var a = window. dialogArguments
Alert ("the parameter you passed is the window object, name:" + a. name)
Script

You can use window. returnValue to return information to the window that opens the dialog box. It can also be an object. For example:

Test4.htm
Script
Var a = window. showModalDialog ("test5.htm ")
For( I %0% I %script%test5.htm
Script
Function sendTo ()
{
Var a = new Array ("a", "B ")
Window. returnValue =
Window. close ()
}
Script



FAQs:
1. How do I submit a window in the modal dialog box without opening a new window?
If your browser is IE5.5 +, you can use an iframe with the name attribute in the dialog box. You can specify the target as the name of the iframe when submitting the request. For IE4 +, you can use a frame with a height of 0. For example:

Test6.htm
Script
Window. showModalDialog ("test7.htm ")
Script test7.htm
If (window. location. search) alert (window. location. search)



Test8.htm

Script
If (window. location. search) alert (window. location. search)
Script


2. You can use http: // servername/virtualdirname/test.htm? Name = mxh method directly transmits parameters to the dialog box?
The answer is no. But it can be in the frame.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.