日期:2014-05-18  浏览次数:20443 次

在线等:(一分钟解绝拿分)子窗口向父窗口传值
问题是这样的:
a.aspx文件中有一个按钮控件,在a.aspx.cs页面触发事件的内容:
Response.Write( " <script   language= 'javascript '> window.open( 'b.aspx ',   'b ',   'height=450,   width=550,   top=120,   left=262,   toolbar=no,   menubar=no,   scrollbars=no,   resizable=no,location=no,   status=no ') </script> ");
就是产生另一个页面b.aspx,我在b.aspx里面加了个按钮控件,点击事件就是将一个参数名为music的值传回a.aspx页面,并且关闭b.aspx页面。
我上网上看了几个帖子,我没看懂,希望大家帮帮忙,给小弟详细的回复。谢谢。

------解决方案--------------------
b里面写一个函数

可以向父窗口 写内容
window.opener.document.write( "This is the parent window ")
同理 可以给父窗口一个全局变量
window.opener.XX=xx;

window.close();//关闭当前
------解决方案--------------------
window.opener.document.getElementById( "父窗口的标签ID ").innerHTML= "你想要向父窗口传递的变量值 ";

这下总该行了吧
------解决方案--------------------
window.ReturnValue= "0 "
var str=window.open()不知道行不行。我用window.showmodeldialog是没问题的
------解决方案--------------------
a.aspx里面写:var returnValue = window.showModalDialog(URL,self, "edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:320px;dialogHeight:300px; ");
b.aspx:


string mfstr = " <script> \n ";
mfstr += "window.returnValue= ' " + returnvalue.Replace( " ' ", "\ ' ") + " '\n ";
mfstr += "window.close()\n ";
mfstr += " </script> \n ";
这样就OK了
------解决方案--------------------
完全JS实现就可以了,给你看看htm页面代码。

a.htm页面:
<input id= "text1 " type= "text " />
<input type= "button " value= "open " onclick= "window.open( 'b.htm ', 'b ', 'height=450, width=550, top=120, left=262, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no ') "/>

b.htm页面
<script>
function getText(){
v = document.getElementById( "textMe ").value;
objP = window.opener.document.getElementById( "text1 ");
objP.value = v;
window.opener = null;
window.close();
}
</script>
输入值 <input id= "textMe " type= "text " />
<input type= "button " value= "把这里输入的值赋值给父窗口中的textbox " onclick= "getText(); "/>
------解决方案--------------------
管间说下,就是父窗休放一个文件框,
当点子窗体时,给父窗体文本框中赋值即可
代码
parent.document.all( "父文本框id ").value = document.all( "子文本框id ").value
------解决方案--------------------
可以这样吧值写到父窗口中去
window.opener.document.all( "父窗口的标签ID ").value= "你想要向父窗口传递的变量值 ";