window.showModalDialog使用手冊(cè)
更新時(shí)間:2007年01月11日 00:00:00 作者:
作者:norika 整理日期:2004年6月17日
基本介紹:
showModalDialog() (IE 4+ 支持)
showModelessDialog() (IE 5+ 支持)
window.showModalDialog()方法用來(lái)創(chuàng)建一個(gè)顯示HTML內(nèi)容的模態(tài)對(duì)話框。
window.showModelessDialog()方法用來(lái)創(chuàng)建一個(gè)顯示HTML內(nèi)容的非模態(tài)對(duì)話框。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
參數(shù)說(shuō)明:
sURL--
必選參數(shù),類型:字符串。用來(lái)指定對(duì)話框要顯示的文檔的URL。
vArguments--
可選參數(shù),類型:變體。用來(lái)向?qū)υ捒騻鬟f參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對(duì)話框通過(guò)window.dialogArguments來(lái)取得傳遞進(jìn)來(lái)的參數(shù)。
sFeatures--
可選參數(shù),類型:字符串。用來(lái)描述對(duì)話框的外觀等信息,可以使用以下的一個(gè)或幾個(gè),用分號(hào)“;”隔開(kāi)。
1.dialogHeight :對(duì)話框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默認(rèn)的單位是em,而IE5中是px,為方便其見(jiàn),在定義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。
下面幾個(gè)屬性是用在HTA中的,在一般的網(wǎng)頁(yè)中一般不使用。
10.dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印預(yù)覽時(shí)對(duì)話框是否隱藏。默認(rèn)為no。
11.edge:{ sunken | raised }:指明對(duì)話框的邊框樣式。默認(rèn)為raised。
12.unadorned:{ yes | no | 1 | 0 | on | off }:默認(rèn)為no。
參數(shù)傳遞:
1.要想對(duì)話框傳遞參數(shù),是通過(guò)vArguments來(lái)進(jìn)行傳遞的。類型不限制,對(duì)于字符串類型,最大為4096個(gè)字符。也可以傳遞對(duì)象,例如:
-------------------------------
parent.htm
<script>
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您傳遞的參數(shù)為:" + obj.name)
</script>
-------------------------------
2.可以通過(guò)window.returnValue向打開(kāi)對(duì)話框的窗口返回信息,當(dāng)然也可以是對(duì)象。例如:
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="http://www.51js.com";
</script>
基本介紹:
showModalDialog() (IE 4+ 支持)
showModelessDialog() (IE 5+ 支持)
window.showModalDialog()方法用來(lái)創(chuàng)建一個(gè)顯示HTML內(nèi)容的模態(tài)對(duì)話框。
window.showModelessDialog()方法用來(lái)創(chuàng)建一個(gè)顯示HTML內(nèi)容的非模態(tài)對(duì)話框。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
參數(shù)說(shuō)明:
sURL--
必選參數(shù),類型:字符串。用來(lái)指定對(duì)話框要顯示的文檔的URL。
vArguments--
可選參數(shù),類型:變體。用來(lái)向?qū)υ捒騻鬟f參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對(duì)話框通過(guò)window.dialogArguments來(lái)取得傳遞進(jìn)來(lái)的參數(shù)。
sFeatures--
可選參數(shù),類型:字符串。用來(lái)描述對(duì)話框的外觀等信息,可以使用以下的一個(gè)或幾個(gè),用分號(hào)“;”隔開(kāi)。
1.dialogHeight :對(duì)話框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默認(rèn)的單位是em,而IE5中是px,為方便其見(jiàn),在定義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。
下面幾個(gè)屬性是用在HTA中的,在一般的網(wǎng)頁(yè)中一般不使用。
10.dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印預(yù)覽時(shí)對(duì)話框是否隱藏。默認(rèn)為no。
11.edge:{ sunken | raised }:指明對(duì)話框的邊框樣式。默認(rèn)為raised。
12.unadorned:{ yes | no | 1 | 0 | on | off }:默認(rèn)為no。
參數(shù)傳遞:
1.要想對(duì)話框傳遞參數(shù),是通過(guò)vArguments來(lái)進(jìn)行傳遞的。類型不限制,對(duì)于字符串類型,最大為4096個(gè)字符。也可以傳遞對(duì)象,例如:
-------------------------------
parent.htm
<script>
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您傳遞的參數(shù)為:" + obj.name)
</script>
-------------------------------
2.可以通過(guò)window.returnValue向打開(kāi)對(duì)話框的窗口返回信息,當(dāng)然也可以是對(duì)象。例如:
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="http://www.51js.com";
</script>
相關(guān)文章
Javascript核心讀書(shū)有感之表達(dá)式和運(yùn)算符
這篇文章主要介紹了Javascript核心讀書(shū)有感之表達(dá)式和運(yùn)算符,十分詳細(xì),需要的朋友可以參考下2015-02-02讓ie運(yùn)行js時(shí)提示允許阻止內(nèi)容運(yùn)行的解決方法
這個(gè)問(wèn)題一般是因?yàn)榫W(wǎng)頁(yè)中使用了一些js代碼,而ie的默認(rèn)安全級(jí)別過(guò)高導(dǎo)致運(yùn)行js時(shí)需要經(jīng)過(guò)準(zhǔn)許才可以。下面是IE的設(shè)置方法。2010-10-10JavaScript中也使用$美元符號(hào)來(lái)代替document.getElementById
JavaScript可以定義$符號(hào)函數(shù),簡(jiǎn)寫(xiě)或書(shū)寫(xiě)兼容性更好的代碼。2010-06-06