假如A页面需要弹出B页面,在比页面关闭时,A页面要拿到B页面的需要值;
思路可以认为是:
1.在A页面中利用Window.Open()方法;
<body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtTest" runat="server"></asp:TextBox> <input id="Button1" type="button" value="button" onclick="window.open('Default.aspx?', 'b', 'height=450, width=550, top=120, left=262, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" />
</div> </form> </body> </html>
2.在弹出的B页面中取得相关值,赋给前台的Value;
利用Window.Opener拿到弹出此页面的页面(父页面)中txtTest控件;
然后赋值,关闭页面;
<head runat="server"> <title>无标题页</title> <script language="javascript" type="text/javascript"> function fun() { var value=document.getElementById("txtValue").value; var txtObjId = window.opener.document.getElementById("txtTest"); txtObjId.value = value; window.opener = null; window.close(); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtValue" runat="server"></asp:TextBox> <input id="Button1" type="button" value="关闭" onclick="fun()" /></div> </form> </body> </html>