javascript弹出子窗口并返回值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
function returnWin(){
window.returnValue
=document.Form2.TextBox1.value;
window.close();
}
</script>


<body>
<form name="Form2" id="Form2">

<input name="TextBox1" id="TextBox1" value="123" type="text" />
<input name="button" value="返回" type="button" onclick="returnWin();" />
</form>
</body>
</html>
1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script> 
function OpenWin(){
    
var str=window.showModalDialog('2.html',document.Form1.TextBox1.value,'help:no');
    
if(str!=null)  {
        document.Form1.TextBox1.value
=str;
    }
}
</script>

<body>
<form name="Form1">
<input name="TextBox1" id="TextBox1" value="1" />
<input type="button" name="Button1" value="打开窗口" onclick="OpenWin();" id="Button1" style="96px;" />
</form>
</html>

2.html

原文地址:https://www.cnblogs.com/didiao/p/1422103.html