showModalDialog:模式窗口, 一種很特別的窗口,當它打開時,后面的父窗口的活動會停止,除非當前的模式子窗口關閉了, 才能操作父窗口.在做網(wǎng)頁Ajax開發(fā)時,我們應該有時會用到它來實現(xiàn)表單的填寫, 或做類似網(wǎng)上答題的窗口. 它的特點是,傳參很方便也很強大,可直接調用父窗口的變量和方法.
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
參數(shù)說明:
sURL--
必選參數(shù),類型:字符串。用來指定對話框要顯示的文檔的URL。
vArguments--
可選參數(shù),類型:變體。用來向對話框傳遞參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對話框通過window.dialogArguments來取得傳遞進來的參數(shù)。
sFeatures--
可選參數(shù),類型:字符串。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號“;”隔開。
1.dialogHeight :
對話框高度,不小于100px,IE4中dialogHeight和dialogWidth默認的單位是em,而IE5中是px,為方便其見,在定義modal方式的對話框時,用px做單位。
2.dialogWidth:
對話框寬度。
3.dialogLeft:
離屏幕左的距離。
4.dialogTop:
離屏幕上的距離。
5.center: {yes | no | 1 | 0 }:
窗口是否居中,默認yes,但仍可以指定高度和寬度。
6.help: {yes | no | 1 | 0 }:
是否顯示幫助按鈕,默認yes。
7.resizable: {yes | no | 1 | 0 }
[IE5+]:是否可被改變大小。默認no。
8.status: {yes | no | 1 | 0 }
[IE5+]:是否顯示狀態(tài)欄。默認為yes[ Modeless]或no[Modal]。
9.scroll:{ yes | no | 1 | 0 | on | off }:
指明對話框是否顯示滾動條。默認為yes。
下面幾個屬性是用在HTA中的,在一般的網(wǎng)頁中一般不使用。
10.dialogHide:{ yes | no | 1 | 0 | on | off }:
在打印或者打印預覽時對話框是否隱藏。默認為no。
11.edge:{ sunken | raised }:
指明對話框的邊框樣式。默認為raised。
12.unadorned:{ yes | no | 1 | 0 | on | off }:
默認為no。
FOR example:
parent.html
<input type="text" id="name" name='name'/>
child.html
<SCRIPT LANGUAGE="JavaScript">
<!--
function setName(){
var win="";
if(window.dialogArguments!=null)
{
//子窗口獲取父窗口的setname函數(shù),并操作賦值
win=window.dialogArguments;
win('Jone');
}
this.close();
}
//-->
</SCRIPT>
<input type="button" value="給父窗口賦值" onclick="setName()"/>
新聞熱點
疑難解答