表单上真的需要动作吗? [英] Is action really required on forms?

查看:118
本文介绍了表单上真的需要动作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里说它是必需的



http://www.w3schools.com/tags/att_form_action.asp



但我发现即使我没有指定动作,表单也会被提交属性,并将表单提交到当前页面,这正是我想要的。

解决方案

要求只有标准即可。完全可以在页面上做任何你想做的事情,而不是遵循标准。如果你这样做,事情可能不会显示或正常工作,但他们可能会。我们的目标是跟随他们,并且这个想法是,如果你关注他们,你的页面将始终工作;您不必担心任何事情。



是的,表单必须在HTML4中具有操作属性。如果未设置,浏览器可能会使用与提供空字符串相同的方法。你真的应该设置 action =这是完全合法的HTML4,遵循标准,并且达到相同的确切结果。



<在HTML5中,您实际上可以在提交按钮本身指定一个操作。如果没有,则使用表单的操作,如果没有设置,则默认为空字符串(请注意,您不能在HTML5中将操作明确设置为空字符串)。


Here it says it's required

http://www.w3schools.com/tags/att_form_action.asp

but I see that forms get submitted even if I don't specify an action attribute, and the form gets submitted to the current page which is exactly what I want.

解决方案

The requirement is only by standards. It is perfectly possible to do whatever you want on a page and not follow standards. Things may not display or work correctly if you do that, but likely they will. The goal is to follow them, and the idea is that if you follow them, your page will always work; you don't have to worry about anything.

Yes, the form is required to have an action attribute in HTML4. If it's not set, the browser will likely use the same method as providing an empty string to it. You really should set action="" which is perfectly valid HTML4, follows standards, and achieves the same exact result.

In HTML5, you can actually specify an action on the submit button itself. If there isn't one, it uses the form's action and if that is not set, it defaults to the empty string (note you cannot explicitly set the action to an empty string in HTML5).

这篇关于表单上真的需要动作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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