且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Javascript form.submit()在Firefox中不起作用

更新时间:2022-12-18 09:41:52

Firefox希望当您提交表单时,至少有一个提交按钮可用,这意味着应该有:

Firefox expects that, when you submit a form, you have at least a submit button available, meaning there should be something like:

<button type="submit">Click me</button>

或:

<input type="submit" value="Click me" />

当您在代码中使用第一个代码时,它将无法正常工作(因为您删除所有按钮提交表格前)。当您使用第二个选项时,它也将在Firefox中运行。你可以在这个小提琴中看到: http://jsfiddle.net/q9Dzc/1/

When you use the first one in your code, it will not work (because you strip out all buttons before submitting the form). When you use the second option, it will work, also in Firefox. As you can see in this fiddle: http://jsfiddle.net/q9Dzc/1/