'Enter key'不会在Firefox中提交表单,但会在Chrome中,为什么? [英] 'Enter key' wont submit form in Firefox, but will in Chrome, why?

查看:136
本文介绍了'Enter key'不会在Firefox中提交表单,但会在Chrome中,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常基本的表单,当我按下回车键时,没有任何反应发生在Firefox中,但在谷歌浏览器中提交。还没有尝试过其他浏览器......



在Firefox中输入时没有任何反应。



当点击提交按钮时,它在两个浏览器中都能正常工作。



表单位于DIV中,表单也包含javascript,这里是简体:

 < form id =nav_form_mainname =nav_form_mainaction =bincgi / sql_query.phptarget =iframe001method = getonSubmit =reset_pager();> 

< input type =buttonname =nav_submitid =nav_submitvalue =SearchonClick =reset_and_subm(); style =width:58px; font-size:13px;>

//一些其他元素...

< / form>

以下是js:

 函数reset_pager(){
byId(p)。value = 0;
}
function reset_and_subm(){
byId(p)。value = 0;
document.forms [nav_form_main]。submit();

code $


reset_pager函数根本不被调用......这很奇怪,因为它是提交功能。所以它就像表单根本没有提交。
然而,目标iframe中的结果显示正常,没有任何问题。



有什么想法?

感谢 仅当< input type =submit> 存在于表单上,为此可以添加一个隐藏的表单,但请记住它会提交表单并绕过 onclick code>>事件,你需要修改表单的 onsubmit 动作以运行你的函数。


I have a form, very basic, and when I hit enter key nothing happens in firefox, but in google chrome it submits. Haven't tried other browsers yet...

Nothing happens at all when hitting enter in firefox.

When clicking the submit button it works fine in both browsers.

The form is inside a DIV, and the form has javascript too, here is the form simplified:

<form id="nav_form_main" name="nav_form_main" action="bincgi/sql_query.php" target="iframe001" method="get" onSubmit="reset_pager();">

<input type="button" name="nav_submit" id="nav_submit" value="Search" onClick="reset_and_subm();" style="width: 58px; font-size: 13px;">

//some other elements...

</form>

and here is the js:

function reset_pager(){
    byId("p").value = 0;
}
function reset_and_subm(){
    byId("p").value = 0;
    document.forms["nav_form_main"].submit();   
}

The reset_pager function is not called at all... which is strange because it is an "onsubmit" function. So it is like the form isn't submitted at all. However, the results in the targeted iframe appear fine, without any problem.

Any ideas?

Thanks

解决方案

Enter for submit is only triggered if <input type="submit> exists on the form. You can add a hidden one for this purpose, but keep in mind that it will submit the form and bypass the onclick event you're looking to capture. You'll need to patch into the onsubmit action of the form to run your function.

这篇关于'Enter key'不会在Firefox中提交表单,但会在Chrome中,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆