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

简介: 1、弹出窗口没有最大最小化,没有滚动条,限制宽和高 this.Response.Write("window.open('d.htm','newwindow','height=100px,width=600px,status=no,toolbar=no, menubar=no,location=no...

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"  onload="self.focus()"   onmouseout="opener.document.body.setCapture()"   onbeforeunload="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很必要

目录
相关文章
|
5月前
layer.open 关闭回调
layer.open 关闭回调
|
3月前
|
Web App开发 存储 缓存
Chrome 开发者工具 Network 里 Failed to load response data 提示消息的含义
Chrome 开发者工具 Network 里 Failed to load response data 提示消息的含义
124 0
|
前端开发
fastadmin ajax 关掉提示信息,Fast.api.ajax关闭提示信息
fastadmin ajax 关掉提示信息,Fast.api.ajax关闭提示信息
862 0
|
Web App开发 开发者
Chrome 开发者工具无法显示服务器正常返回的 HTTP 请求 - Failed to load response data
Chrome 开发者工具无法显示服务器正常返回的 HTTP 请求 - Failed to load response data
715 0
Chrome 开发者工具无法显示服务器正常返回的 HTTP 请求 - Failed to load response data
window.open常用参数具体意义
window.open常用参数具体意义