国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Javascript showModalDialog兩個窗體之間傳值

2024-05-06 14:13:47
字體:
來源:轉載
供稿:網友
Javascript 兩個窗體之間傳值實現代碼
javascript中還有一個函數window.showModalDialog也可以打開一個新窗體,不過他打開的是一個模態窗口,那么如何在父窗體和子窗體之間傳值呢?我們先看該函數的定義:vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
參數說明:
sURL--必選參數,類型:字符串。用來指定對話框要顯示的文檔的URL。
vArguments--可選參數,類型:變體。用來向對話框傳遞參數。傳遞的參數類型不限,包括數組等。對話框通過window.dialogArguments來取得傳遞進來的參數。
sFeatures--可選參數,類型:字符串。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號“;”隔開。
dialogHeight :對話框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默認的單位是em,而IE5中是px,為方便其見,在定義modal方式的對話框時,用px做單位。
dialogWidth: 對話框寬度。
dialogLeft: 離屏幕左的距離。
dialogTop: 離屏幕上的距離。
center: {yes | no | 1 | 0 }:窗口是否居中,默認yes,但仍可以指定高度和寬度。
help: {yes | no | 1 | 0 }:是否顯示幫助按鈕,默認yes。
resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改變大小。默認no。
status: {yes | no | 1 | 0 } [IE5+]:是否顯示狀態欄。默認為yes[ Modeless]或no[Modal]。
scroll:{ yes | no | 1 | 0 | on | off }:指明對話框是否顯示滾動條。默認為yes。
如:"dialogWidth=200px;dialogHeight=100px"
因此我們可以通過window.dialogArguments參數來在兩個窗體之間傳值
如下面兩個頁面:FatherPage.htm:
代碼如下:
<script type="text/javascript">
function OpenChildWindow()
{
window.showModalDialog('ChildPage.htm',document.getElementById('txtInput').value);
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />

ChildPage.htm:
代碼如下:
<body onload="Load()">
<script type="text/javascript">
function Load()
{
document.getElementById('txtInput').value=window.dialogArguments ;
}
</script>
<input type="text" id="txtInput" />
</body>

上面只是傳遞簡單的字符串,我們還可以傳遞數組,如:FatherPage.htm:
XML-Code:
代碼如下:
<script type="text/javascript">
function OpenChildWindow()
{
var args = new Array();
args[0] = document.getElementById('txtInput').value;
window.showModalDialog('ChildPage.htm',args);
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />ChildPage.htm:
XML-Code:
<script type="text/javascript">
function Load()
{
document.getElementById('txtInput').value=window.dialogArguments[0] ;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 三穗县| 万山特区| 清苑县| 和田市| 合水县| 清流县| 都匀市| 陕西省| 东乡| 津南区| 庆城县| 通城县| 许昌市| 北辰区| 闽清县| 巴彦县| SHOW| 桐梓县| 长子县| 宜州市| 嘉荫县| 龙游县| 资兴市| 华阴市| 玉山县| 汶上县| 宁强县| 凤山市| 纳雍县| 金门县| 林口县| 永平县| 南岸区| 虹口区| 延川县| 浦东新区| 浦东新区| 汪清县| 应用必备| 德惠市| 涿州市|