window.open('your.htm','WinName')打开窗口时指定相同的名称(WinName)就行啦

解决方案 »

  1.   

    不行的,因为使用了一样的窗口名称,虽然我设定了新的属性,比如大小,scrolling bar等等,但是都不会变化的,都是原来打开的时候的样子。怎么让他用新的我设定的属性呢?
      

  2.   

    可以在A窗口中定义一个变量var C1Window,当从A窗口中打开C1窗口时,用C1Window=window.open(...);表示,当C1窗口关闭时,调用self.opener.C1Window=null。这样当在B窗口中要打开C2时,只要判断A窗口中的C1Window是否为空就可以可以了。
      

  3.   

    定义一个变量COPEN=0,如果C1是打开的就,COPEN=1,再配合WINDOW.OPEN()就可以解决了!
      

  4.   

    a=window.open()
    判断:
    if(a && a.open && !a.closed)
    a.focus()
      

  5.   

    test1.htm
    --------------------------------------1
    <input type="button" value="open" onclick="test()"><script>
    var winFlag = Math.random();function test()
    {
    var w = window.open('http://www.weiqi.net', 'haha', "height=100,width=100,status=yes,toolbar=no,menubar=no,location=no");
    if (w.opener.winFlag != self.winFlag)
    {
    w.close();
    window.open('http://www.weiqi.net', 'haha', "height=100,width=100,status=yes,toolbar=no,menubar=no,location=no");
    }
    }
    </script>
    test2.htm
    --------------------------------2
    <br>
    <input type="button" value="open" onclick="test()"><script>
    var winFlag = Math.random();function test()
    {
    var w = window.open('http://www.weiqi.net', 'haha', "height=300,width=300,status=yes,toolbar=no,menubar=no,location=no");
    if (w.opener.winFlag != self.winFlag)
    {
    w.close();
    window.open('http://www.weiqi.net', 'haha', "height=300,width=300,status=yes,toolbar=no,menubar=no,location=no");
    }
    }
    </script>
      

  6.   

    谢谢楼上的解答。我有一个问题,可不可以if (w.opener.winFlag != self.winFlag)--〉if (w.opener != self)这样的比较呢?假如可以的话,就不需要你的那个变量了。
      

  7.   

    inelm(木野狐) :其实,还有一个问题,就是,假如我关掉了你先打开的窗口的那个html,然后在执行你的余下的那个html,一样还是有问题的。和和。就是,
    1。打开test1.html;
    2。test2.html;
    3。点击test1.html上面的open按钮,然后关掉test1.html;
    4。点击test2.html上面的open按钮,这个时候javascript就有错误了。所以,我觉得,应该放一个变量到那个子窗口上面,通过那个变量来比较,这样可能是没有问题的。但是没有测试过。