gpt4 book ai didi

javascript - 'Enter key' 不会在 Firefox 中提交表单,但在 Chrome 中会,为什么?

转载 作者:太空狗 更新时间:2023-10-29 14:05:32 25 4
gpt4 key购买 nike

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

在 Firefox 中按回车键时什么也没有发生。

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

表单在一个DIV里面,表单也有javascript,这里是简化的表单:

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

这是js:

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

reset_pager 函数根本没有被调用...这很奇怪,因为它是一个“onsubmit”函数。所以就像根本没有提交表格一样。但是,目标 iframe 中的结果看起来很好,没有任何问题。

有什么想法吗?

谢谢

最佳答案

Enter 仅在 <input type="submit> 时触发提交存在于表格中。您可以为此添加一个隐藏的,但请记住,它将提交表单并绕过 onclick。您要捕捉的事件。您需要修补到 onsubmit运行函数的表单操作。

关于javascript - 'Enter key' 不会在 Firefox 中提交表单,但在 Chrome 中会,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2364141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com