我有一个自定义对话框,它接受用户输入并根据用户输入提交表单。这个javascript在IE和Firefox上运行良好。它有时也适用于铬,但有时没有反应。
<html>
<head>
<script type="text/javascript">
window.onblur = function() {
window.focus();
}
var realtimePoLink = "./processAbc.do";
var realtimePoMethod = "startAbc";
var nightlyPoLink = "./processXyz.do";
var nightlyPoMethod= "startXyz";
function startPO(){
var historyPoRadio = document.getElementById("nightlyPoRadio");
if(historyPoRadio !=null && historyPoRadio.checked == true){
document.getElementById("method").value = nightlyPoMethod;
document.getElementById("poStartForm").action = nightlyPoLink;
}
else{
document.getElementById("method").value = realtimePoMethod;
document.getElementById("poStartForm").action = realtimePoLink;
}
document.forms["poStartForm"].submit();
window.close();
}
</script>
</head>
<body>
<form name="poStartForm" id ="poStartForm" method="POST" action="" target="ASSIAMainWindow">
<input type="hidden" name="tn" value="0000010019">
<input type="hidden" name="portId" value="">
<input type="hidden" name="method" id="method" value="startPo">
<input type="hidden" name="confirmation" value="YES">
<table>
<tr>
<td>
<input type="radio" name="poSourceValue" value="1" checked="checked">
<td>ABC
</tr>
<tr>
<td>
<input type="radio" name="poSourceValue" value="2">
<td>MNO
</tr>
<tr>
<td>
<input type="radio" name="poSourceValue" value="3" id="nightlyPoRadio">
<td>XYZ
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" value="Start" onclick="javascript:startPO();"/>
<input type="button" value="Cancel" onclick="javascript:window.close();"/>
</tr>
</table>
</form>
</body>
</html>
无论是否提交表单,对话框始终关闭。