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)
始终表示为空,即使我在模式对话框中单击确定按钮。 我该怎么做才能说明按下确定按钮时用户在列表中选择的选项,按下取消按钮时是否为空?