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>