日期:2014-05-16  浏览次数:20325 次

window.dialogArguments[0].open的窗口和父窗口的关系
window.dialogArguments[0].open的窗口和父窗口的关系?也就是说反过来怎么写,从子窗口怎么访问父窗口,别告诉我是window.opener哦,这个是不对的

------解决方案--------------------
window.showModalDialog( url, window );

然后在弹开窗口中:
window.dialogArguments 即为父窗口window对象的引用。想搞什么都可以了。
------解决方案--------------------
看楼主的意思子窗口应该是用window.showModalDialog()弹出的模式对话框.
父窗口中弹出时这么写:window.showModalDialog( '子窗口.aspx ',window, '.... ');
注意第二个参数用window,这样你就把父窗口对象当做参数传递给了子窗口.
然后在子窗口中就可以通过window.dialogArguments来引用父窗口对象了.
就向楼上说的,你想怎么搞都行了...
举个例子,你可以在子窗体关闭的时候刷新父窗体,可以这么写:
window.dialogArguments.location.href=window.dialogArguments.location.href;
window.focus();
window.close();
你也可以调用主窗口里的函数:
window.dialogArguments.函数名();

------解决方案--------------------
例子
1.htm
===========
<title> 1 </title>
<input type=button value= "open 2 " onclick= "window.showModalDialog( '2.htm ',window); ">
<script>
alert( "1 ")
</script>


2.htm
===========
<title> 2 </title>
<frameset cols= "0,* ">
<frame src= " ">
<frame src= "b.htm ">
</frameset>

b.htm
==========
<input type=button value= "open 3 " onclick= "window.showModalDialog( '3.htm ',window); ">
<script>
alert( "我是2 ")
</script>


3.htm
=========
<title> 3 </title>
<frameset cols= "0,* ">
<frame src= " ">
<frame src= "c.htm " name= "x ">
</frameset>


c.htm
=====
<input type= "button " value= "refresh 2 and close me " onclick= "window.dialogArguments.location= '2.htm ';window.parent.close() ">


注意:showModalDialog缓存的厉害,请清空缓存每次测试