Two common methods for Js pop-up box port and return value _ javascript skills

Source: Internet
Author: User
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.
Related Article

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.