我在父窗口中用window.open打开了很多个子窗口,现在我想在子窗口关闭的事件里调用父窗口的方法,改变父窗口的变量的值,请问我怎样才能捕获到子窗口的关闭的事件? 最好使用jquery来实现。
下面是我实现的方式,但是没有效果:$(document).ready(function () {
var activityInstId = $('#activityInstId').val();
var processInstId = $('#processInstId').val();
var key=activityInstId+"_"+processInstId;
alert(key);
window.opener.addLogFrame(key,this);

 
});
$(document).unload( function () {
var activityInstId = $('#activityInstId').val();
var processInstId = $('#processInstId').val();
var key=activityInstId+"_"+processInstId;
alert('---------close----------');
window.opener.delLogFrame(key,this);
window.close();
} );

解决方案 »

  1.   

    jquery在这方面做的不好用js吧,其实子页面不一定是关闭,跳转到父页面就可以了
    page1.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script language="JavaScript" type="text/javascript">
        function openWin(u, w, h) {
                  var l = (screen.width - w) / 2;
                  var t = (screen.height - h) / 2;
                   var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
                      s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no';
                   open(u, 'oWin', s);
           }
       function openIt(){
        window.open("page2.html",400,300);
       }
      </script></head><body>
    <input type="text" id="text1" />
    <input type="button" value="弹出" onclick="openIt()" />
    </body>
    </html>

    page2.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script language="JavaScript" type="text/javascript">
       function goback(obj){
        window.opener.document.getElementById("text1").value = obj.value;
        window.close();
       }
    </script>
    </head><body>
    <div><input type="button" value="阿会楠" onclick="goback(this)" /></div>
    <div><input type="button" value="23岁" onclick="goback(this)" /></div>
    </body>
    </html>