简体   繁体   English

表单提交按钮在 Firefox 中不起作用,但在 Chrome 或 IE 中有效

[英]Form submit button does not work in Firefox but works in Chrome or IE

I have a form with some input fields and a submit button.我有一个包含一些输入字段和提交按钮的表单。 The form should submit to a servlet.表单应提交给 servlet。

When I hit submit/return, everything is fine in Chrome or IE, but it does nothing on Firefox.当我点击提交/返回时,在 Chrome 或 IE 中一切正常,但在 Firefox 上没有任何作用。 Any idea about the issue?对这个问题有什么想法吗?

HTML: HTML:

<body>
    <div align="center">
    <form>

        <table cellpadding ='2' border ='0'>
        <tr>
            <td>
                <label for="Database">Database</label>
            </td>
            <td>
                <input id="database" type="text" onchange="setdirtybit()" name="Database" style="width:200px"></input>
            </td>
        </tr>
        <tr>
            <td>
                <label for="Script">Script</label>
            </td>
            <td>
                <input id="script" type="text" onchange="setdirtybit()" name="Script" style="width:200px"></input>
            </td>
        </tr>
        </table>
        <br />
            <input type ='submit' value='Submit' onclick='Close()'></input>
    </form>
    </div>
</body>

JavaScript: JavaScript:

function Close()
    {
        window.returnValue = "";
        if(window.dirtyFlag)
        {
            document.forms[0].method="post";
        document.forms[0].action="/nbreports/updates/";
        document.forms[0].submit();
            window.returnValue =    getValue('database') + '/' +
                        getValue('script') ;
        }
        window.close();
    }

    function getValue(varName)
    {
        if(document.getElementById(varName) == null)
            return "";
        if(document.getElementById(varName).value == null)
            return "";
        else
            return document.getElementById(varName).value;
    }

    function setdirtybit()
    {
        window.dirtyFlag = 1;
    }
$('#mytextfield').change(function(e) {
    $('input[type=submit]').focus();
});

put an Id on your submit button, them do like this:在你的提交按钮上放一个 ID,他们这样做:

$(document).ready(function(){
    $('#submitButtonId').click(function(){
        var url = 'myServletUrlHere';
        var data = $('form').serialize();

        $.ajax({
            type: 'POST',
            url: url,
            data: data,
            success: alert("It worked!")
        });
    });
});

I am not sure but I do know that the following form does not work in Firefox but it works in all the other browsers:我不确定,但我知道以下表单在 Firefox 中不起作用,但在所有其他浏览器中都有效:

<form method="POST">
<textarea rows="4" cols="60" name="body"></textarea><br>
<input type="submit" value="Submit">
</form>

It's like the submit button doesn't even process the mouse clicks.就像提交按钮甚至不处理鼠标点击一样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .unbind(&#39;submit&#39;)。submit()在Chrome / IE中有效,但在Firefox中无效 - .unbind('submit').submit() works in Chrome/IE but doesn't work in Firefox Angular 2/4:nativeElement.submit()在Firefox中不提交表单,但在chrome中工作 - Angular 2/4 : nativeElement.submit() does not submit form in Firefox, but works in chrome 当提交按钮被隐藏时,通过按回车来提交表单; 在 Firefox 中工作,在 Chrome 中什么都不做 - Submitting a form by hitting return when the submit button is hidden; works in Firefox, does nothing in Chrome 提交按钮不适用于Chrome或Firefox,但适用于Internet Explorer - The Submit Button doesn't work in Chrome or Firefox, but Works in Internet Explorer 元素点击不适用于Firefox和IE,但适用于Chrome - Element click does not work in Firefox and IE but works in Chrome Ajax提交可在Chrome / Safari中运行,但不能在Firefox / IE中运行 - Ajax submit works in Chrome/Safari but not Firefox/IE [0].submit 不适用于 IE 和 Firefox,在 Chrome 中完美运行 - [0].submit not working in IE and Firefox, works perfect in Chrome extJS和IE提交按钮损坏,但在Firefox中有效 - extJS and IE submit button broken but works in firefox 提交按钮可在Chrome中使用,但不能在Firefox或IE中使用 - Submit button working in Chrome but not Firefox or IE $(&#39;。button&#39;)。on(“ DOMSubtreeModified”)在chrome / safari中无效,但在Firefox中有效 - $('.button').on(“DOMSubtreeModified”) does not work in chrome/safari, but works in Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM