弹出页面传值回主页面

来源:互联网 发布:modbus tcp单片机编程 编辑:程序博客网 时间:2024/05/16 07:38

Main.html

 

<html>
<head>
</head>
<body>
<script language="javascript" type="text/javascript">
function Open()
{
window.open('b.html');
}
</script>
<form>
<input type="text" id="txtParent"><a href="#" onclick="Open()">Open Window</a>
</form>
</body>
</html>

 

alert.html

 

<html>
<head>
</head>
<script language="javascript" type="text/javascript">
function SetValueForParent()
{
parent.opener.document.all("txtParent").value=document.getElementById('test').value;
window.close();
}
</script>
<body>
Values:<br/>
<input type="text" id="test" value="">
<input type="button" value="确定" onclick="SetValueForParent();">
</body>
</html>

原创粉丝点击