子窗口与父窗口的控制,及参数传递:window.showModalDialog、window.open、iframe 子窗口与父窗口的控制.htm: <!-- Description: 子窗口与父窗口的控制,及参数传递:window.showModalDialog、window.open、iframe Author: xiaolong Date: 2009-08-14 11:30:33 --> <mce:script type="text/javascript"><!-- function pA(){ alert("parent_alert"); } window.open("子窗口与父窗口的控制_1.htm"); var obj=new Object(); obj.name="test_long"; // --></mce:script> <table id="pT" border="1"> <tr> <td id="pTd" οnclick="pA()">table_td</td> </tr> </table> <form name="pF"> <input type="hidden" name="pIn" οnclick="pA()"> <input type="button" value="模态对话框_传递参数" οnclick="alert(window.showModalDialog('子窗口与父窗口的控制_1.htm',obj))"> <br><br> <input type="button" value="模态对话框_2" οnclick="alert(window.showModalDialog('子窗口与父窗口的控制_1.htm',window))"> </form> <iframe width="1000" height="200" src="子窗口与父窗口的控制_1.htm" mce_src="子窗口与父窗口的控制_1.htm"> </iframe> 子窗口与父窗口的控制_1.htm: test1.htm <mce:script type="text/javascript"><!-- var obj = window.dialogArguments; alert("您传递的参数为:" + obj.name); window.returnValue="/test_by_long"; function sA(){ //window.parent.pA(); parent.pA(); } function sI(){ //parent.document.all.pIn.click(); self.parent.document.pF.pIn.click(); } function sT(){ //parent.document.all.pTd.click(); window.opener.document.all.pTd.click(); } function sP(){ window.dialogArguments.document.all.pTd.click(); } // --></mce:script> <br><br> <input type="button" value="直接调用父窗口函数pA()[iframe]" οnclick="sA()"></input><br><br> <input type="button" value="通过父窗口按钮调用pA()[iframe]" οnclick="sI()"></input><br><br> <input type="button" value="通过父窗口表格单元格调用pA()[弹窗]" οnclick="sT()"></input><br><br> <input type="button" value="通过父窗口表格单元格调用pA()[弹窗]" οnclick="sP()"></input><br><br>