1
溝通我在HTA,看起來像這樣一個javascript:模態對話框不與主HTA窗口
var result = null;
window.showModalDialog("dialog.hta", window, "dialogHeight:300px; dialogWidth:300px");
alert(result);
dialog.hta:
<html>
<head>
<title>Dialog box</title>
<meta http-equiv="MSThemeCompatible" content="yes"/>
</head>
<body style="background:#F0F0F0">
<select id="colors">
<option selected>Red</option>
<option>Blue</option>
<option>Green</option>
<option>Yellow</option>
</select><br/>
<script type="text/javascript">
function ok(){
window.dialogArguments.result = colors.getElementsByTagName("option")[colors.selectedIndex].innerHTML;
window.close();
}
</script>
<button onclick="ok()">OK</button>
<button onclick="window.close()">Cancel</button>
</body>
</html>
的問題是,當我按確定主要HTA窗口中的alert(result)
始終表示爲空,即使我在模式對話框中單擊確定按鈕。 我該怎麼做才能說明按下確定按鈕時用戶在列表中選擇的選項,按下取消按鈕時是否爲空?