<!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 type="text/javascript">
var G_hSubWin=null;function popWin(sUrl){
var sCfg="menubar=no,toolbar=no,statusbar=no"
        +",left=200,top=200,width=500,height=300"
G_hSubWin=window.open(sUrl,"__PopWin",sCfg);
}window.onunload=function(){
if(G_hSubWin)
G_hSubWin.close();
}
</script>
</head>
<body>
<input type="button" value="打开" onclick="popWin('http://www.baidu.com')"/>
</body>
</html>

解决方案 »

  1.   

    这样不行了,我的是用这个showModelessDialog函数打开的窗体,用close()关闭,说没权限啊.
      

  2.   

    showModelessDialog页面跳转时,本来子窗口就会自动关闭的
    <script >
    var a=window.showModelessDialog("2.htm");
    </script>
    <a href="3.htm">aaa</a>
      

  3.   

    window.showModelessDialog
    这个本来就是父窗体的一部分,和alert差不多
      

  4.   

       showModelessDialog 它可以返回一个值,如: var winObj= showModelessDialog(xx,xx,xx,xx) ,你使用 winObj.close(); 试试。
      

  5.   

    已解决,是因为的调用showModelessDialog()的网页,是嵌在有两个frameset网页中的