javascript的window.open()詳解

來源:互聯網
上載者:User

javascript的window.open()詳解

通過按鈕開啟一個新視窗,並在新視窗的狀態列中顯示當前年份。
1)在主視窗中應用以下代碼添加一個用於開啟一個新視窗的按鈕:

 
<script type=text/javascript language=java> function win(){ window.open('newWindow.jsp','newwindow','width=400,height=200,status=yes'); } </script>

(2)建立一個新的JSP檔案,名稱為newWindow.jsp,在該檔案中添加以下用於顯示當前年份的代碼:

<script language=javascript>   var mydate = new Date();   var year = 現在是: + mydate.getFullYear() + 年;   document.write(year);</script>

window.open()基本文法
window.open(pageurl,windowname,parameters)
其中:
pageurl 為子視窗路徑
windowname 為子視窗控制代碼
parameters 為視窗參數(各參數用逗號分隔)
樣本

<script language=javascript>window.open ('page.jsp','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') </script>

各項參數:

alwaysLowered | yes/no | 指定視窗隱藏在所有視窗之後 alwaysRaised  | yes/no | 指定視窗懸浮在所有視窗之上 depended      | yes/no | 是否和父視窗同時關閉 directories   | yes/no | Nav2和3的目錄欄是否可見 height        | pixel value | 視窗高度 hotkeys       | yes/no | 在沒功能表列的視窗中設安全退出熱鍵 innerHeight   | pixel value | 視窗中文檔的像素高度 innerWidth    | pixel value | 視窗中文檔的像素寬度 location      | yes/no | 位置欄是否可見 menubar       | yes/no | 功能表列是否可見 outerHeight   | pixel value | 設定視窗(包括裝飾邊框)的像素高度 outerWidth    | pixel value | 設定視窗(包括裝飾邊框)的像素寬度 resizable     | yes/no | 視窗大小是否可調整 screenX       | pixel value | 視窗距螢幕左邊界的像素長度 screenY       | pixel value | 視窗距螢幕上邊界的像素長度 scrollbars    | yes/no | 視窗是否可有滾動欄 titlebar      | yes/no | 視窗題目欄是否可見 toolbar       | yes/no | 視窗工具列是否可見 Width         | pixel value | 視窗的像素寬度 z-look        | yes/no | 視窗被啟用後是否浮在其它視窗之上

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.