彈出窗口及關閉總結(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"  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很必要


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM