Example of _javascript between JS operation modal windows and parent-child windows

Source: Internet
Author: User
Parent.hmtl
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> parent Window </title>
<script type= "Text/javascript" >

Window.onload=function () {
var Btn=document.getelementbyid ("btn");
Btn.onclick=function () {
var obj={
Test: "John to child window",
Win:window
};
var returnvalue = window.showModalDialog ("child.html", obj, "dialogleft:100px;dialogtop:100px;dialogwidth:400px"; Dialogheight:300px;resizable:yes ");
if (returnvalue!= null) {
document.getElementById ("Content"). InnerHTML = returnvalue;
}
};
}
</script>
<body>
<div id= "Content" style= "margin:50px;width:100px;height:150px;border:5px solid #0000ff;" ></div>
<input type= "button" id= "btn" value= "Popup child Window" >
</body>

Child.html
Copy code code as follows:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
<meta http-equiv= "Content-type" content= "text/html charset=utf-8" >
<title> child windows </title>
<script type= "Text/javascript" >
Window.onload=function () {
//Get URL's arguments
var args = Window.dialogarguments;
var win = args.win;//Parent Window object
Var content=document.getelementbyid ("content");
Content.value=args.test;
var Btn=document.getelementbyid ("btn"); The
Btn.onclick=function () {
//modal dialog box values
Window.returnvalue = Content.value;
Window.close ();
}


</script> <body>
<input type= "text" id= "content" >< ; Input type= "button" id= "btn" value= "Send value to parent window" >
</body>
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.