彈出窗口的命令詳解
文章來源:365jz.com 點(diǎn)擊數(shù):
457 更新時(shí)間:2009-09-24 22:27
參與評(píng)論
1、window.open(pageURL,name,parameters) pageURL 為彈出窗口路徑;name 為彈出窗口名稱,也可以是系統(tǒng)自帶的比如:_self, _blank,_top,_parent ... ;parameters 為窗口參數(shù)(各參數(shù)用逗號(hào)分隔) ;各項(xiàng)參數(shù) 其中yes/no也可使用1/0,pixel value為具體的數(shù)值,單位象素。 參數(shù) | 取值范圍 | 說明 alwaysLowered | yes/no | 指定窗口隱藏在所有窗口之后 alwaysRaised | yes/no | 指定窗口懸浮在所有窗口之上 depended | yes/no | 是否和父窗口同時(shí)關(guān)閉 directories | yes/no | Nav2和3的目錄欄是否可見 height | pixel value | 窗口高度 hotkeys | yes/no | 在沒菜單欄的窗口中設(shè)安全退出熱鍵 innerHeight | pixel value | 窗口中文檔的像素高度 innerWidth | pixel value | 窗口中文檔的像素寬度 location | yes/no | 位置欄是否可見 menubar | yes/no | 菜單欄是否可見 outerHeight | pixel value | 設(shè)定窗口(包括裝飾邊框)的像素高度 outerWidth | pixel value | 設(shè)定窗口(包括裝飾邊框)的像素寬度 resizable | yes/no | 窗口大小是否可調(diào)整 screenX | pixel value | 窗口距屏幕左邊界的像素長(zhǎng)度 screenY | pixel value | 窗口距屏幕上邊界的像素長(zhǎng)度 scrollbars | yes/no | 窗口是否可有滾動(dòng)欄 titlebar | yes/no | 窗口題目欄是否可見 toolbar | yes/no | 窗口工具欄是否可見 Width | pixel value | 窗口的像素寬度 z-look | yes/no | 窗口被激活后是否浮在其它窗口之上 常用示例:window.open ('page.html', 'newwindow', 'fullscreen'); //全屏window.open ('page.html', '_self', 'fullscreen = yes , height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no'); // 在當(dāng)前頁面彈出一個(gè)全屏的窗口,并有詳細(xì)的設(shè)置popWin = window.open('test.jsp'); // 獲取彈出窗口對(duì)象,以便進(jìn)行操作 popWin .focus(); // 聚焦窗口 2、window.alert()參數(shù),只有一個(gè),顯示警告框的信息;無返回值。3、window.confirm() 參數(shù)就只有一個(gè)。顯示提示框的信息。按確定,返回true;按取消返回false。 4、window.prompt()參數(shù),有兩個(gè),第一個(gè)參數(shù),顯示提示輸入框的信息。第二個(gè)參數(shù),用于顯示輸入框的默認(rèn)值。返回,用戶輸入的值。 5、window.showModalDialog()方法用來創(chuàng)建一個(gè)顯示HTML內(nèi)容的模態(tài)對(duì)話框。window.showModelessDialog()方法用來創(chuàng)建一個(gè)顯示HTML內(nèi)容的非模態(tài)對(duì)話框。
showModalDialog()與showModelessDialog()的區(qū)別,在于showModalDialog()打開的窗口,置在父窗口上,必須關(guān)閉才能訪問父窗口;showModelessDialog(),打開后不必關(guān)閉也可訪問父窗口打開的窗口。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures]);vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures]);參數(shù)說明: sURL-- 必選參數(shù),類型:字符串。用來指定對(duì)話框要顯示的文檔的URL。 vArguments-- 可選參數(shù),類型:變體。用來向?qū)υ捒騻鬟f參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對(duì)話框通過window.dialogArguments來取得傳遞進(jìn)來的參數(shù)。 sFeatures-- 可選參數(shù),類型:字符串。用來描述對(duì)話框的外觀等信息,可以使用以下的一個(gè)或幾個(gè),用分號(hào)隔開。 1.dialogHeight :對(duì)話框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默認(rèn)的單位是em,而IE5中是px,為方便其見,在定義modal方式的對(duì)話框時(shí),用px做單位。 2.dialogWidth: 對(duì)話框?qū)挾取?3.dialogLeft: 離屏幕左的距離。 4.dialogTop: 離屏幕上的距離。 5.center: {yes | no | 1 | 0 }:窗口是否居中,默認(rèn)yes,但仍可以指定高度和寬度。 6.help: {yes | no | 1 | 0 }:是否顯示幫助按鈕,默認(rèn)yes。 7.resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改變大小。默認(rèn)no。 8.status: {yes | no | 1 | 0 } [IE5+]:是否顯示狀態(tài)欄。默認(rèn)為yes[ Modeless]或no[Modal]。 9.scroll:{ yes | no | 1 | 0 | on | off }:指明對(duì)話框是否顯示滾動(dòng)條。默認(rèn)為yes。 參數(shù)傳遞: 要想對(duì)話框傳遞參數(shù),是通過vArguments來進(jìn)行傳遞的。類型不限制,對(duì)于字符串類型,最大為4096個(gè)字符。也可以傳遞對(duì)象,例如: 調(diào)用頁面
<script> var obj = new Object(); obj.name="LOVEJS"; window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px"); </script> 對(duì)話框頁面
<script> var obj = window.dialogArguments ;alert("您傳遞的參數(shù)為:" + obj.name) </script> 獲取對(duì)象:可以通過window.returnValue向打開對(duì)話框的窗口返回信息,當(dāng)然也可以是對(duì)象。例如: 調(diào)用頁面<script> str = window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px"); alert(str); </script> 對(duì)話框頁面<script> window.returnValue="在這里進(jìn)行你要的操作"; </script>
如對(duì)本文有疑問,請(qǐng)?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會(huì)為你解答!! 點(diǎn)擊進(jìn)入論壇
------分隔線----------------------------