Window. showmodaldialog user manual box

Source: Internet
Author: User

Basic Introduction:
Showmodaldialog () (ie 4 + supported)
Showmodelessdialog () (ie 5 + supported)
The window. showmodaldialog () method is used to create a modal dialog box that displays HTML content.
The window. showmodelessdialog () method is used to create a non-modal dialog box that displays HTML content.
Usage:
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.
----------------
1. dialogheight: dialog box height, not smaller than 100px
2. dialogwidth: Dialog Box width.
3. dialogleft: the distance from the left of the screen.
4. dialogtop: the distance from the screen.
5. Center: {Yes | no | 1 | 0}: whether to center. The default value is yes, but the height and width can still be specified.
6. Help: {Yes | no | 1 | 0}: whether to display the Help button. The default value is yes.
7. resizable: {Yes | no | 1 | 0} [ie5 +]: whether the size can be changed. No by default.
8. Status: {Yes | no | 1 | 0} [ie5 +]: whether to display the status bar. The default value is Yes [modeless] or no [modal].
9. Scroll: {Yes | no | 1 | 0 | on | off}: whether to display the scroll bar. The default value is yes.

The following attributes are used in HTA and are not used in general web pages.
10. dialoghide: {Yes | no | 1 | 0 | on | off}: whether the dialog box is hidden when printing or previewing. The default value is no.
11. Edge: {sunken | raised}: Specify the border style of the dialog box. The default value is raised.
12. unadorned: {Yes | no | 1 | 0 | on | off}: No by default.

Parameter transfer:
1. 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:
-------------------------------
Parent.htm
<SCRIPT>
VaR OBJ = new object ();
OBJ. Name = "51js ";
Window. showmodaldialog ("modal.htm", OBJ, "dialogwidth = 200px; dialogheight = 100px ");
</SCRIPT>
Modal.htm
<SCRIPT>
VaR OBJ = Window. dialogarguments
Alert ("the parameter you passed is:" + obj. Name)
</SCRIPT>
-------------------------------
2. You can use window. returnvalue to return information to the window that opens the dialog box. It can also be an object. For example:
------------------------------
Parent.htm
<SCRIPT>
STR = Window. showmodaldialog ("modal.htm", "dialogwidth = 200px; dialogheight = 100px ");
Alert (STR );
</SCRIPT>
Modal.htm
<SCRIPT>
Window. returnvalue = "http://homepage.yesky.com ";
</SCRIPT>

()

Today I see in my book
Showmodaldialog seems to be a bit outdated. I have been searching for it online for a long time and found that this article is good. I don't know who the original author is.

Javascript 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 open a window with showmodelessdialog (), we do not need to close it with window. Close (). When we open the window in non-modal mode [ie5,
You can still perform other operations in the window that opens the dialog box, that is, the dialog box is not always the top focus. When the window URL that opens it changes, it is automatically closed. 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 during print or preview. The default value is no.

Edge
: {Sunken | raised}: Specify the border style of the dialog box. The default value is raised.

Unadorned
: {Yes | no | 1 | 0 | on | off}: The default value is no.



(Example)

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Script language = "JavaScript" type = "text/JavaScript">
Function opendialog ()
{
Window. showmodaldialog ("http://www.sosuo8.com", "", "dialogwidth = 300px; dialogheight = 200px; status = no; help = no; scroll = No ")
}
</SCRIPT>
<Title> untitled document </title>
</Head>

<Body>
<Button onclick = "opendialog ();"> open </button>
</Body>
</Html>

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)
</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 <A. length; I ++) Alert (A [I])
</SCRIPT>


Test5.htm
==============================

<SCRIPT>
Function sendto ()
{
VaR A = new array ("A", "B ")
Window. returnvalue =
Window. Close ()
}
</SCRIPT>
<Body>
<Form>
<Input value = "return" type = button onclick = "sendto ()">
</Form>


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 as an example,

Test6.htm
==============================

<SCRIPT>
Window. showmodaldialog ("test7.htm ")
</SCRIPT>


Test7.htm
==============================

If (window. Location. Search) Alert (window. Location. Search)
<Frameset rows = "0, *">
<Frame src = "about: blank">
<Frame src = "test8.htm">
</Frameset>


Test8.htm
==============================

<Form target = "_ Self" method = "get">
<Input name = TXT value = "test">
<Input type = submit>
</Form>
<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.