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>