一个网页一共有4个按钮,其中3个按钮,分别用window.open()事件,打开3个网页。
最后一个按钮是重登陆按钮,点击该按钮时将打开的网页都关闭。如何写?
<html>
<head>
<script>
function openwindowXX(url, winName, width, height)
{
    
  if(winName==05){
cc=window.open( url,winName,width=1024,height=768);
}
if(winName==06){
ca=window.open( url,winName,width=1024,height=768 );
}
if(winName==07){
cb=window.open( url,winName,width=1024,height=768);
}
 
}
</script>
</head>
<body>
<table>
<tr>
<td width="90" height="26" >
          <a style="cursor:hand" href="javascript:openwindowXX('a.html','05');"><img border="0" src="/images/top/top_menu_05up.jpg" name="img05"></a>
       </td><td width="90" height="26" >
          <a style="cursor:hand" href="javascript:openwindowXX('b.html','06');"><img border="0" src="/images/top/top_menu_06up.jpg" name="img06"></a>
       </td><td width="90" height="26" >
          <a style="cursor:hand" href="javascript:openwindowXX('c.html','07');"><img border="0" src="/images/top/top_menu_07up.jpg" name="img07"></a>
       </td>
<td><input type="button" value="重登陆"/></td>
  </tr>
</table>
</body>
</html>

解决方案 »

  1.   

    <input type="button" onclick="cc.close();cb.close();ca.close()" value="重登陆"/> 
      

  2.   

    可以实现:<html>
    <head>
    <script>
    function openwindowXX(url, winName, width, height)
    {
       
    if(winName==05){
    cc=window.open( url,winName,width=1024,height=768);
    }
    if(winName==06){
    ca=window.open( url,winName,width=1024,height=768 );
    }
    if(winName==07){
    cb=window.open( url,winName,width=1024,height=768);
    }}
    </script>
    </head>
    <body>
    <table>
    <tr>
    <td width="90" height="26" >
            <a style="cursor:hand" href="javascript:openwindowXX('http://www.scriptlover.com','05');"> open </a>
          </td> <td width="90" height="26" >
            <a style="cursor:hand" href="javascript:openwindowXX('http://www.scriptlover.com','06');"> open </a>
          </td> <td width="90" height="26" >
            <a style="cursor:hand" href="javascript:openwindowXX('http://www.scriptlover.com','07');"> open </a>
          </td>
    <td> <input type="button" value="重登陆" onclick="cc.close();ca.close();cb.close();" /> </td>
      </tr>
    </table>
    </body>
    </html> 
      

  3.   

    拉拉拉...其实我们写的都是有问题的...
    close前应该先
    if(ca)//或者其他两个嘛~哈哈~
      

  4.   

    上面的代码有些问题,比如:我要打开一个网页,然后点击“重登陆”时候,就会报其中的一个未定义,"cc"未定义,或者是"ca"未定义,怎么解决?
      

  5.   

    我4楼说了.关闭前先加if(ca)等判断.不然对象都没赋值.当然未定义啦...
    like thisif(ca)ca.close();//这个不会出错.ca.close();//这个在没打开ca那窗口的时候运行肯定出错.