JS 用window.open()函数,父级页面如何取到子级页面的返回值?

时间:2023-12-23 09:42:38
父窗口:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
// alert($("test1").val());
// $("#text").val($("test1").val()); $("#Button1").click(function () { var win = window.open("../WebForm1.aspx", null, " height=300,width=450, Left=300px,Top=20px, menubar=no,titlebar=no,scrollbar=no,toolbar=no, status=no,location=no"); }); } );
</script> </head>
<body>
<form id="form1" runat="server">
<div>
<input name="text" id="text1" type="text" /><input type="button" id="Button1"/> <asp:Button ID="Button2" runat="server" Text="Button" />
</div>
</form>
</body>
</html>

子窗口:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<title></title>
<script type="text/javascript"> function Button1_onclick() {
window.opener.$("#text1").val("ddd");
// alert(window.opener.$("#text1").val());
self.close();

} </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="submit" id="Button1" onclick="return Button1_onclick()" />
</div>
</form>
</body>
</html>