The two common methods of Js popup and return value _javascript skill

Source: Internet
Author: User
1.window.showmodaldialog (Url,args,dialogattrs)
Parameter description:
URL: Pop-up page address
AGRs: The main window to the dialog box parameters, can be any type (array can also)
Dialogattrs: Pop-up window style parameters
Modal dialog box usage:
Main window: var value =window.showmodaldialog (' test.jsp ', STRs, ' resizable:yes ');
In the pop-up box, you set the return value by Window.returnvalue, and the value above gets this, and then the main window
This value is processed to enable interactive processing
Note: The modal dialog box is applied in its return value, can return a simple character channeling, can return an array, modeless dialog box similar
2. window.open:
"Parent Window"
Copy Code code 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.txt0.value = TextValue;
}
Else
{
window. close ();
Child.close ();
}
}*/
}
</script>
<a href= "Javascript:show_child ();" > Open child windows </a>
<form name=frm0>
<input type= "text" name= "txt0" id= "txt0" >/Note You must write the id attribute here otherwise FF cannot get the value
</form>

"Child Window"
Copy Code code as follows:

<script>
function Choseitem ()
{
var v= "";
var check_item = Document.frm.item;
for (i=0;i<check_item.length;i++)
{
if (check_item[i].checked)
{
v+= "," +check_item[i].value;
}
Document.frm.txt.value=v.replace (/^,{1}/, "");
}
}
function foo ()
{
window. close ();
window. Opener.document.getElementById ("Txt0"). Value=document.getelementbyid ("TXT"). Value
}
</script>
<body>
<form name=frm>
<input type=checkbox name=item value=1 onclick= "Choseitem ();" >a
<input type=checkbox name=item value=2 onclick= "Choseitem ();" >b
<input type=checkbox name=item value=3 onclick= "Choseitem ();" >c
<input type=checkbox name=item value=4 onclick= "Choseitem ();" >d
<input type=text name= "txt" id= "TXT" >
</form>
<input Type=button value= "Close" "onclick=" foo (); " >
</body>

Summary: Under normal circumstances, windows.open because the custom more, therefore uses windows.open more, above many page editors like to use the ShowModalDialog, really does not know which, Use window.open, many mature CMS systems are used window.open.

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.