当前位置: 代码迷 >> ASP.NET >> 关于关闭对话框的有关问题?
  详细解决方案

关于关闭对话框的有关问题?

热度:503   发布时间:2013-02-25 00:00:00.0
关于关闭对话框的问题??
我在父页面使用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>

------解决方案--------------------------------------------------------
弹出的那个页面head里 加入
<base target="_self" />

例如:
<head>
<base target="_self" />
</head>

这个绝对可以,亲测。
  相关解决方案