1

我有一个自定义对话框,它接受用户输入并根据用户输入提交表单。这个 javascript 在 IE 和 Firefox 上运行良好。它有时也适用于 chrome,但有时没有响应。

<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>

不管表单是否提交,对话框总是关闭的。

4

0 回答 0