弹出窗口及关闭总结(window.open();Response.Redirect(); 模态)

1、弹出窗口没有最大最小化,没有滚动条,限制宽和高

this.Response.Write("<script language=javascript>window.open('d.htm','newwindow','height=100px,width=600px,status=no,toolbar=no, menubar=no,location=no,scrollbars=no,resizeable=no,top=300,left=200')</script>");

 

 

2、关闭

 Response.Write("<script   language=javascript> window.opener=null;self.close();</script>");  

 

3、弹出窗体居中

  aspx定义

 <script  type="text/javascript">

  function openwindow(url,name,iWidth,iHeight)
    {
     var url;                                 //转向网页的地址;
     var name;                           //网页名称,可为空;
     var iWidth;                          //弹出窗口的宽度;
     var iHeight;                        //弹出窗口的高度;
     var iTop = (window.screen.availHeight-30-iHeight)/2;       //获得窗口的垂直位置;
     var iLeft = (window.screen.availWidth-10-iWidth)/2;           //获得窗口的水平位置;
     window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
   }

</script>  

 

调用
 openwindow("a.aspx?sitenoname="+escape(message),'newwindow',800,530);

 

 

4、主窗体弹出子窗体,用window.open()实现模态窗口效果(结合3的openwindow())

主窗体

openwindow("a.aspx?sitenoname="+escape(message),'newwindow',800,530);

 

子窗体a.aspx做以处理

<body  class="body"  οnlοad="self.focus()"   οnmοuseοut="opener.document.body.setCapture()"   οnbefοreunlοad="opener.document.body.releaseCapture()">

 

5、结合4,在主窗体用window.open()打开了一个子窗体a.aspx,在子窗体a.aspx中用模态弹出打开了b.aspx,然后b.aspx页面中点击某一链接直接在本页转向c.aspx页。

 

子窗体a.aspx.cs中

Page.ClientScript.RegisterStartupScript(this.GetType(), "", " <script language='javascript'>window.showModalDialog('b.aspx',window,'dialogheight:530px;   dialogwidth:800px;center:yes; menubar:no;status:no;help:no;scroll:yes;resizable:no;location:no') </script>");

 

子窗体b.aspx.cs中

<head>
 <base target="_self" />       //这个处理非常必要,否则一直会总有弹出状态
</head>

 

子窗体b.aspx.cs页面中直接在本页转向c.aspx页

Response.Redirect("Band.aspx", false);        //false很必要

 

 

 

 

 

 


   
  

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值