用window.open("",name) 打开一个IE子窗口后,
如何在父窗口通过子窗口名字(name),来判断该子窗口有没有被关闭了?请各位大侠指教!

解决方案 »

  1.   

    当window.open()时候在页面赋予一个变量的值,而当 子页面关闭时候修改这个值
    然后而就可以判断是否关闭了
      

  2.   

    var a= window.open('','a');
    function test(){alert(a.closed);}
      

  3.   


    var a= window.open();
    function onunload(){
    if (a){
    a.close();//关闭打开的子页面
    }
    }
      

  4.   

    谢谢楼上3位的回答,我这情况有点特殊,
    补充一个说明:
    var a= window.open();我现在的父页面已经取不到  a  这个窗口引用了。
    只有这个字窗口的名字。这种情况下,如何做呢?
      

  5.   

    var win = window.open("","win");
    if(win && !win.closed) alert("Opened.");
    else alert("closed");
      

  6.   


    var a= window.open('','a');
     
    if (a.closed) {
    alert("close");
    } else {
    alert("No close");
    }
    a.close();
    if (a.closed) {
    alert("close");
    } else {
    alert("No close");
    }
      

  7.   

    看看是否是你想要的效果:<html>
    <body>
    <script language=javascript>
    var timer
    var winOpen
    function IfWindowClosed() {
    if (winOpen.closed == true) {
    alert("close");
    window.clearInterval(timer);
    }
    }
    function done(){
    winOpen=window.open();
    timer=window.setInterval("IfWindowClosed()",500);
    }
    </script>
    <input type="button" name="btnOpen" value="open" onclick="done();"/>
    </body>
    </html>
      

  8.   

    为什么会得不到子窗口?
    var newWindow = window.open('','newWindow','height=300,width=300,scrollbars=auto');   
        if (newWindow) 
        {
    alert("得到"); 
    }得不到吗?
      

  9.   

    <script>
    var mywin = window.open("http://www.g.cn");
    var myTime = setInterval(function(){ 
    if (mywin.closed) {
    alert("窗口已关闭!");
    clearInterval(myTime)

    },100);
    </script>
      

  10.   


    <SCRIPT   LANGUAGE= "JavaScript"> 
    <!-- 
    var newWindow = window.open('','newWindow','height=300,width=300,scrollbars=auto');  
    function ttt(){
        try 
        {
         newWindow.document;
    alert("得到"); 
    }catch(e){
    alert("得不到");
    }
    }
    //--> 
    </SCRIPT>
    <input type="button" onclick="ttt()">
      

  11.   

    >现在的父页面已经取不到  a  这个窗口引用了。 
    >为什么啊??? 
    >大多数情况下就是向大伙那么做的啊!!!因为父页面可以刷新和迁移,一刷新和迁移。
    任何对象的都不能保存了。
      

  12.   


    winOpen 这个对象,我在画面上是不存在的了。
    因为打开了子画面后,父画面发生迁移。
      

  13.   


    本来是想这样的:
    test.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>
    <title>Welcome To Scripting</title>
    <style>
    </style>
    </head><body>
    <div id="folder">
    </div>
    <script language=javascript>
    window.open('test2.html');
    </script>
    <input type='button' onclick='if(window.subwin)alert(window.subwin.closed)' value='a closed?'/>
    </body></html>test2.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>
    <title>Welcome To Scripting</title>
    <style>
    </style>
    <script>
    window.onunload=function(){
    window.opener.subwin = window;
    }
    </script>
    </head><body>
    <div id="folder">
    </div>
    </body></html>不过如果你说是页面刷新和转移的话.这样也没啥用了.除非他没转移.只是刷新.并且刷新后到窗口关闭前没有再刷新.