关于父子窗口间交互的问题


如果使用window.showModalDialog()打开子窗口的话,可以用parent.function()调用父窗口的方法。例如:
  var RtnVal = window.showModalDialog(sUrl, this, "dialogHeight:255px;dialogWidth:605px;status:no;help:no");
    if (RtnVal == '1') (若窗口成功打开,在后台用Response.Write ("<script>window.returnValue='1';window.close();</script>");返回一个值'1')
        parent.SetCustomOperation("DWLocation");

如果使用window.open()打开子窗口,可以使用window.opener.function()来条用父窗口的方法。

另外使用window.open()打开子窗口,关于字父窗口传值的问题,见如下例子:
例如:页面AAA.htm 用 window.open方式弹出页面 BBB.htm 。
在页面BBB.htm上选择一个值,确定关闭窗口后将选择的这个值返回到父窗口AAA.htm。
AAA.htm得到返回的值后,给本页面上的文本框赋值。
if(window.opener)window.opener.document.getElementById("theTextAreaId").value = value;

另外关于用iframe的子父窗口之间的交互问题,本博客也有提到。
posted @ 2009-06-03 09:40  周文  阅读(313)  评论(0编辑  收藏  举报