showModalDialog
參數(shù)詳細(xì)說(shuō)明
使用
showModalDialog
顯示數(shù)據(jù)
,
因?yàn)榫彺娴脑?/p>
,
有時(shí)候數(shù)據(jù)不會(huì)立即更新
,
所以需要在
HTML
頁(yè)面的
Head
標(biāo)簽內(nèi)添加使網(wǎng)頁(yè)過(guò)期的語(yǔ)句
,
這樣才能使
showModalDialog
數(shù)據(jù)能夠得
到及時(shí)的更新:
<meta http-equiv="pragram" content="no-cache">
禁止瀏覽器從本地緩存中調(diào)閱頁(yè)面。
網(wǎng)頁(yè)不保存在緩存中,每次訪問(wèn)都刷新頁(yè)面。
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
網(wǎng)頁(yè)不保存在緩存中,必須重新加載頁(yè)面
<meta http-equiv="expires" content="0">
網(wǎng)頁(yè)在緩存中的過(guò)期時(shí)間為
0
,一旦網(wǎng)頁(yè)過(guò)期,必須從服務(wù)器上重新訂閱。
基本介紹:
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ì)話框高度,不小于100
px
,IE4中
dialogHeight
和
dialogWidth
默認(rèn)的單位是
em
,
而IE5中是
px
,
為方便其見(jiàn),
在定義
modal
方式的對(duì)
話框時(shí),用
px
做單位。
2.dialogWidth:
對(duì)話框?qū)挾取?/p>
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