WEB頁(yè)子窗口(showModalDialog和showModelessDialog)使用說(shuō)明
更新時(shí)間:2009年10月25日 10:59:00 作者:
WEB頁(yè)子窗口(showModalDialog和showModelessDialog)使用說(shuō)明,大家可以看下。
使用環(huán)境:
showModalDialog IE4以上版本
showModelessDialog IE5以上
區(qū)別:
showModalDialog 被打開(kāi)后就會(huì)始終保持輸入焦點(diǎn)。無(wú)法操作主窗口,除非關(guān)閉對(duì)話(huà)框。
showModelessDialog 被打開(kāi)后,用戶(hù)可以隨機(jī)切換輸入焦點(diǎn)。只是主窗口被對(duì)話(huà)框擋住。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
參數(shù)說(shuō)明:
sURL 必選參數(shù),類(lèi)型:字符串。用來(lái)指定對(duì)話(huà)框要顯示的文檔的URL。
vArguments 可選參數(shù),類(lèi)型:變體。用來(lái)向?qū)υ?huà)框傳遞參數(shù)。傳遞的參數(shù)類(lèi)型不限,包括數(shù)組等。對(duì)話(huà)框通過(guò)window.dialogArguments來(lái)取得傳遞進(jìn)來(lái)的參數(shù)。
sURLsFeatures 可選參數(shù),類(lèi)型:字符串。用來(lái)描述對(duì)話(huà)框的外觀等信息,可以使用以下的一個(gè)或幾個(gè),用分號(hào)“;”隔開(kāi)。
1.dialogHeight 對(duì)話(huà)框高度,不小于100px,IE4中dialogHeight和dialogWidth 默認(rèn)的單位是em,而IE5中是px
2. dialogWidth: 對(duì)話(huà)框?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 }:是否顯示滾動(dòng)條。默認(rèn)為yes。
10. dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印預(yù)覽時(shí)對(duì)話(huà)框是否隱藏。默認(rèn)為no。
11. edge:{ sunken | raised }:指明對(duì)話(huà)框的邊框樣式。默認(rèn)為raised。
12. unadorned:{ yes | no | 1 | 0 | on | off }:默認(rèn)為no。
例子:
f.html
<html>
<head>
<title>主窗口</title>
<script type="text/javascript">
<!--
var child;
function openDialogBox()
{
child = window.showModalDialog('c.html',document.all["txt"],"dialogWidth=500px;dialogHeight=200px;");
}
//-->
</script>
</head>
<body>
<input name="txt" type="text" disabled="disabled" />
<input name="btn" type="button" value="打開(kāi)對(duì)話(huà)框" onClick="openDialogBox();" />
</body>
</html>
c.html
<html>
<head>
<title>對(duì)話(huà)框</title>
<script type="text/javascript">
<!--
function set()
{
window.dialogArguments.value=document.all["txt"].value
}
//-->
</script>
</head>
<body>
<input name="txt" type="text"/>
<input name="btn" type="button" value="設(shè)置" onClick="set();" />
</body>
</html>
showModalDialog IE4以上版本
showModelessDialog IE5以上
區(qū)別:
showModalDialog 被打開(kāi)后就會(huì)始終保持輸入焦點(diǎn)。無(wú)法操作主窗口,除非關(guān)閉對(duì)話(huà)框。
showModelessDialog 被打開(kāi)后,用戶(hù)可以隨機(jī)切換輸入焦點(diǎn)。只是主窗口被對(duì)話(huà)框擋住。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
參數(shù)說(shuō)明:
sURL 必選參數(shù),類(lèi)型:字符串。用來(lái)指定對(duì)話(huà)框要顯示的文檔的URL。
vArguments 可選參數(shù),類(lèi)型:變體。用來(lái)向?qū)υ?huà)框傳遞參數(shù)。傳遞的參數(shù)類(lèi)型不限,包括數(shù)組等。對(duì)話(huà)框通過(guò)window.dialogArguments來(lái)取得傳遞進(jìn)來(lái)的參數(shù)。
sURLsFeatures 可選參數(shù),類(lèi)型:字符串。用來(lái)描述對(duì)話(huà)框的外觀等信息,可以使用以下的一個(gè)或幾個(gè),用分號(hào)“;”隔開(kāi)。
1.dialogHeight 對(duì)話(huà)框高度,不小于100px,IE4中dialogHeight和dialogWidth 默認(rèn)的單位是em,而IE5中是px
2. dialogWidth: 對(duì)話(huà)框?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 }:是否顯示滾動(dòng)條。默認(rèn)為yes。
10. dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印預(yù)覽時(shí)對(duì)話(huà)框是否隱藏。默認(rèn)為no。
11. edge:{ sunken | raised }:指明對(duì)話(huà)框的邊框樣式。默認(rèn)為raised。
12. unadorned:{ yes | no | 1 | 0 | on | off }:默認(rèn)為no。
例子:
f.html
復(fù)制代碼 代碼如下:
<html>
<head>
<title>主窗口</title>
<script type="text/javascript">
<!--
var child;
function openDialogBox()
{
child = window.showModalDialog('c.html',document.all["txt"],"dialogWidth=500px;dialogHeight=200px;");
}
//-->
</script>
</head>
<body>
<input name="txt" type="text" disabled="disabled" />
<input name="btn" type="button" value="打開(kāi)對(duì)話(huà)框" onClick="openDialogBox();" />
</body>
</html>
c.html
復(fù)制代碼 代碼如下:
<html>
<head>
<title>對(duì)話(huà)框</title>
<script type="text/javascript">
<!--
function set()
{
window.dialogArguments.value=document.all["txt"].value
}
//-->
</script>
</head>
<body>
<input name="txt" type="text"/>
<input name="btn" type="button" value="設(shè)置" onClick="set();" />
</body>
</html>
相關(guān)文章
javascript操作html控件實(shí)例(javascript添加html)
幾乎HTML所有標(biāo)記都可以說(shuō)是HTML的控件,如select, input, div, table等。html標(biāo)簽便捷的操作,深受大家的喜歡。如何使用javascript來(lái)操作HTML控件,下面我介紹下比較麻煩的幾個(gè)控件2013-12-12JavaScript中Date.toSource()方法的使用教程
這篇文章主要介紹了JavaScript中Date.toSource()方法的使用教程,用來(lái)返回日期為字符串,是JS入門(mén)學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-06-06JavaScript While 循環(huán)基礎(chǔ)教程
只要指定條件為 true,循環(huán)就可以一直執(zhí)行代碼,2007-04-04JavaScript parseInt()與Number()區(qū)別案例詳解
這篇文章主要介紹了JavaScript parseInt()與Number()區(qū)別案例詳解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-09-09