我在父页面使用window.showModalDialog()打开一个对话框,这是父页面,点击“选择”按钮打开对话框:这是对话框:对话框中有一个<button id="Button1" onclick="closed()">关闭</button>按钮,
function closed() {
        window.opener = null;
        window.close();
    }
点击后正常应该是关闭对话框。
我为什么我点击后的结果却是对话框关闭了,但是却打开了一个新的页面中再次打开了该对话框???
如下图:
实在是搞不明白,请各位大侠指点!!!!以下是对话框页面的页面代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="baseDataValuesetDialog.aspx.cs" Inherits="baseDataValuesetDialog" %><!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 runat="server">
    <title>无标题页</title>
    <LINK href="Images/index/YHChannelApply.files/Style.css" type=text/css rel=stylesheet />
    <LINK href="Images/index/YHChannelApply.files/Manage.css" type=text/css rel=stylesheet />
    <style type="text/css">
        .tdclass
        {
             text-align:right;
        }
        .manageHead1 {
BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; COLOR: #000000; BORDER-BOTTOM: #cccccc 1px solid; 
}
    </style>
</head>
<script type="text/javascript">
    function closed() {
        window.opener = null;
        window.close();
    }
</script>
<body>
    <form id="form1" runat="server">
    <div>
    
        <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
              <TBODY>
              <TR>
                <TD width=15><IMG src="Images/index/YHChannelApply.files/new_019.jpg" border=0 /></TD>
                <TD width="100%" background=Images/index/YHChannelApply.files/new_020.jpg height=20></TD>
                <TD width=15><IMG src="Images/index/YHChannelApply.files/new_021.jpg" border=0 /></TD>
              </TR>
              </TBODY>
         </TABLE>         <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
            <TBODY>
                <TR>
                    <TD width=15 background=Images/index/YHChannelApply.files/new_022.jpg>
                        <IMG src="Images/index/YHChannelApply.files/new_022.jpg" border=0 /> 
                    </TD>
                    <TD vAlign=top width="100%" bgColor=#ffffff>
                        <TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
                            <TR>
                                <TD class=manageHead>当前位置: <asp:Label ID="lb_url" runat="server"></asp:Label></TD>
                            </TR>
                            <TR>    
                                <TD height=2>
                                    </TD>
                            </TR>
                        </TABLE>
                        
                        
                        <TABLE borderColor=#cccccc cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
                            <TBODY>
                                <TR>
                                    <TD>
                                        <TABLE cellSpacing=1 cellPadding=2 width="100%" border=0>
                                            <TBODY>
                                                <tr>
                                                        <TD class=manageHead1>
                                                    <TABLE width="100%" border=0>
                                                    <tr>
                                                    <td class=manageHead1>
                                                        <asp:TreeView ID="TreeView1" runat="server"></asp:TreeView>
                                                    </td>
                                                    </tr>
                                                    <TR>
                                    <TD align=right style="height: 25px">
                                        &nbsp;&nbsp;
                                        &nbsp;
                                        &nbsp;
                                        &nbsp;
                                        <asp:Button ID="checked" runat="server" Text="确定" OnClick="checkedNode" />
                                        &nbsp;
                                            <button id="Button1" onclick="closed()">关闭</button>
                                            
                                    </TD>
                                </TR>
                                                        </TABLE>
                                                        </TD>
                                                </tr>
                                            </TBODY>
                                        </TABLE>
                                    </TD>
                                </TR>
                            </TBODY>
                        </TABLE>
                        
                        </td>
                        
                    <TD width=15 background=Images/index/YHChannelApply.files/new_023.jpg>
                        <IMG src="Images/index/YHChannelApply.files/new_023.jpg" border=0 /> 
                    </TD>
                    </tr>
                    </TBODY>
                    </TABLE>
               
         
         
         <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
            <TBODY>
              <TR>
                <TD width=15 style="height: 15px"><IMG src="Images/index/YHChannelApply.files/new_024.jpg" border=0 /></TD>
                <TD align="center" width="100%" background=Images/index/YHChannelApply.files/new_025.jpg style="height: 15px"></TD>
                <TD width=15 style="height: 15px"><IMG src="Images/index/YHChannelApply.files/new_026.jpg" border=0 /></TD>
              </TR>
            </TBODY>
         </TABLE>
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   

    我使用<input type="button" id="bt_close" onclick="javascript:window.close();" value="关闭" />这种方式就不会产生上述问题,可是我需要操作TreeView控件,一定要到后台。要么有什么方法可以在js里面操作TreeView么??
      

  2.   

    终于发现了最简单的解决方法:
    function onsubmit() // 强制本窗口提交
        {
            document.getElementById("form1").target = "_self";
        }
    添加这个方法后,就行了。
    比其他的什么iframe,frame啊好多了。
      

  3.   

    弹出的那个页面head里 加入
    <base target="_self" />例如:
    <head>
        <base target="_self" />
    </head>这个绝对可以,亲测。