Use of the showmodaldialog function)

Source: Internet
Author: User

In this example, a modal window is displayed, and two methods for receiving and passing parameters are demonstrated. At the same time, multiple variables returned by the modal window can be accepted.

Showmodaldialog help can refer to Microsoft msdn http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp
AA. htm

Bytes --------------------------------------------------------------------------------------------------------------------------
<HTML>

<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> main interface </title>
</Head>

<Body>
<Form ID = "getform"> return value: <input type = "text" id = "getdata" readonly> <input type = "text" id = "getdata1" readonly>

</Form>
< Input type = "button" value = "open new window 1" onclick = "openwin1 ()">
< Input type = "button" value = "open new window 2" onclick = "openwin2 ()" >
< Script Language =" Javascript " >
Function Openwin1 ()
{
VaR srcfile = "bb.htm"; // document name in the new window
VaR winfeatures = "dialogheight: 300px; dialogleft: 200px ;";
VaR OBJ = getform; // pass form as an object to a new window
Window. showmodaldialog (srcfile, OBJ, winfeatures );
}
Function Openwin2 ()
{
VaR srcfile = "cc.htm"; // document name in the new window
VaR winfeatures = "dialogheight: 300px; dialogleft: 200px ;";
VaR OBJ = getform. getdata. value; // pass form as an object to the new window
VaR STR = Window. showmodaldialog (srcfile, OBJ, winfeatures );
If (STR! = NULL)
Document. getform. getdata. value = STR;
}

</SCRIPT>

</Body>

</Html>

BB. htm

Important: when you call the aspx file in the pop-up window, you must add the following to the page_load event:Code
Response. expires = 0; response. cache. setnostore (); response. appendheader ("Pragma", "No-Cache ");
Otherwise, the page is the last cache and will not change.

Bytes ------------------------------------------------------------------------------------------------------------------------
<HTML>

<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> New window BB </title>
</Head>

<Base target = "_ Self"><! -- This sentence is very important. You only need to add it to ensure that the server code is called in the pop-up window instead of a new window. -->
<Body>
<Form ID = "sendform"> enter the following information:
<Input type = "text" id = "writedata">
<Input type = "text" id = "writedata1">
<Input type = "button" value = "return to parent window" onclick = "Send (sendform. writedata. Value, sendform. writedata1.value);">
</Form>
< Script Language ="Javascript " >
Function Send (Val, val1)
{
// Obtain the object passed by the parent window
VaR myobj = Window. dialogarguments;
// Assign a value
Myobj. getdata. value = val;
Myobj. getdata1.value = val1;
// Close the window
Window. Close ();
}
</SCRIPT>

</Body>

</Html>

Cc. htm
Bytes ------------------------------------------------------------------------------------------------------------------------
<HTML>

<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> New window CC </title>
</Head>

<Base target = "_ Self"><! -- This sentence is very important. You only need to add it to ensure that the server code is called in the pop-up window instead of a new window. -->
< Body >
<Form Id = "sendform"> enter the following information:
< Input Type = "text" id = "writedata">
< Input Type = "button" value = "return to parent window" onclick = "Send (sendform. writedata. Value);">
</ Form >
< Script Language =" Javascript " >
Function Send (VAL)
{
Window. returnvalue = Val
Window. Close ();
}
</ Script >

</Body>

</Html>

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.