日期:2014-05-20  浏览次数:20603 次

如何获取window.open中的值
点击A页面中的某个按钮,弹出B页面(.htm),B页面中有文本框可以输入数据,我想在点击B页面中的提交按钮时,关闭B页面,同时在A页面中获取文本框中输入的数据。请问如何实现?

------解决方案--------------------
A页面: <HTML>
<HEAD>
<title> A </title>
<meta name= "GENERATOR " Content= "Microsoft Visual Studio .NET 7.1 ">
<meta name= "CODE_LANGUAGE " Content= "C# ">
<meta name= "vs_defaultClientScript " content= "JavaScript ">
<meta name= "vs_targetSchema " content= "http://schemas.microsoft.com/intellisense/ie5 ">
<script language= "javascript ">
function opennew()
{
var returnstr=window.showModalDialog( "B.aspx ");
var a=document.getElementById( "TextBox1 ");
a.value=returnstr;
}
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id= "Form1 " method= "post " runat= "server ">
<asp:Button id= "Button1 " style= "Z-INDEX: 101; LEFT: 288px; POSITION: absolute; TOP: 184px " runat= "server "
Text= "Button " > </asp:Button>
<asp:TextBox id= "TextBox1 " style= "Z-INDEX: 102; LEFT: 280px; POSITION: absolute; TOP: 120px "
runat= "server "> </asp:TextBox>
</form>
</body>
</HTML>
B:页面 <HTML>
<HEAD>
<title> B </title>
<meta name= "GENERATOR " Content= "Microsoft Visual Studio .NET 7.1 ">
<meta name= "CODE_LANGUAGE " Content= "C# ">
<meta name= "vs_defaultClientScript " content= "JavaScript ">
<meta name= "vs_targetSchema " content= "http://schemas.microsoft.com/intellisense/ie5 ">
<script language= "javascript ">
function closeit()
{
var a=document.getElementById( "TextBox1 ");
parent.returnValue=a.value;
//event.srcElement.value=a.value;
//var b=parent.parent.getElementById( "TextBox1 ");
// alert(b);
//b.value=a.value;
parent.close();


}
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id= "Form1 " method= "post " runat= "server ">
<asp:TextBox id= "TextBox1 " style= "Z-INDEX: 101; LEFT: 312px; POSITION: absolute; TOP: 128px "
runat= "server "> </asp:TextBox>
<asp:Button id= "Button1 " style= "Z-INDEX: 102; LEFT: 376px; POSITION: absolute; TOP: 224px " runat= "server "
Text= "Button "> </asp:Button>
</form>
</body>
</HTML>
分别把javascript函数写进button 的onclick