Sometimes we need to execute some code in the new window and return the execution result to this page, then we need the following method. Common js methods are as follows.
1. window. showModalDialog (url, args, dialogattrs)
Parameter description:
Url: the url of the pop-up page.
Agrs: parameters passed to the dialog box in the main window, which can be of any type (array or)
Dialogattrs: style parameters in the pop-up window
Mode dialog box usage:
Main window: var value = window. showModalDialog ('test. js', strs, 'resizable: Yes ');
In the pop-up box, use window. returnValue to set the return value. The value obtained above is the value, and you can
This value is processed for interaction.
Note: the application of the mode dialog box lies in its return value. It can return simple escape characters or arrays. The non-mode dialog box is similar
2. Window. open:
Parent window]
The Code is as follows:
Script
Function show_child ()
{
Var child = window. open ("child.html", "child", "height = 200, width = 400, status = yes, toolbar = no, menubar = no, location = no ");
/* If (! Child. closed)
{
If (! Window. close ())
{
Var textValue = frm.txt. value; parent.frm0.txt 0. value = textValue;
}
Else
{
Window. close ();
Child. close ();
}
}*/
}
Script
Open subwindow
Subwindow]
The Code is as follows:
Script
Function choseItem ()
{
Var v = "";
Var check_item = document. frm. item;
For (I = 0; I {
If (check_item [I]. checked)
{
V + = "," + check_item [I]. value;
}
Document.frm.txt. value = v. replace (/^, {1 }/,"");
}
}
Function foo ()
{
Window. close ();
Window .opener.doc ument. getElementById ("txt0"). value = document. getElementById ("txt"). value
}
Script
Summary: windows. because there are many user-defined open, windows is used. there are many open pages. Many Web editors prefer showModalDialog. If you don't know which one to use, you can use window. open. Many mature cms systems use Windows. open.