如何用JavaScript关闭子窗体

 这几天正在做项目,感觉自己还是进步了一点,但是想把自己在项目中遇到的问题和解决方法记录一下,以免下次在出错,同时也和大家分享一下,也希望大家知道.

首先有这样一段JavaScrip代码,我在一个页面里想打开另外一个页面ShowDialogfrm.aspx.

function OpenWindow(strUrl) { window.showModalDialog("ShowDialogfrm.aspx", strUrl, "dialogHeight:600px;dialogWidth:825px;resizable:yes"); }

然后我在后端代码里加了一个HyperLink控件,名字叫perLinkUnitName,给它加属性,如下:

perLinkUnitName.Attributes.Add("onclick","OpenWindow(ShowDialogfrm.aspx.?strAutoNo=" + strAutoNo + "&IsEdit=" + IsEdit + "')");
    perLinkUnitName.NavigateUrl="#";

这是你如果在ShowDialogfrm.aspx窗体中加一个客户端按钮,写上JavaScript的关闭按钮,你会发现怎么也关闭不了窗口,而且还摸明奇妙的弹出一些窗体.

 

解决方法:

我在加一个showbak.aspx页面,html代码如下:

然后你把父窗体中的打开的窗体的名字改成上面那个窗体的名字即可

 

< html >
  
< head >
    
< title > 网页对话框 </ title >
    
< meta name = " GENERATOR "  Content = " Microsoft Visual Studio .NET 7.1 " >
    
< meta name = " CODE_LANGUAGE "  Content = " C# " >
    
< meta name = vs_defaultClientScript content = " JavaScript " >
    
< meta name = vs_targetSchema content = " http://schemas.microsoft.com/intellisense/ie5 " >
    
< script language = " javascript "  type = " text/javascript " >
        function PostQueryString()
        
{
            var  urlstr 
= window.dialogArguments;
            mainfrm.document.location 
= urlstr;
        }

        
</ script >
  
</ head >
  
< frameset rows = " * "  onload = " PostQueryString() " >
        
< frame name = " mainfrm "  src = "" >
        
< noframes >
            
< p id = " p1 " >
                This page requires frames, but your browser does not support them.
            
</ p >
        
</ noframes >
    
</ frameset >
</ html >

 

 

function OpenWindow(strUrl) ... { window.showModalDialog("ShowBak.aspx", strUrl, "dialogHeight:600px;dialogWidth:825px;resizable:yes"); }  

 

<script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script> <script language="javascript" type="text/javascript"> function btnShow_OnClick(strUrl) { window.showModalDialog("ShowDialogfrm.aspx",strUrl,"dialogHeight:700px;dialogWidth:800px;resizable:yes"); } </script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值