本文介绍了动作之间的差异=“”和动作=“#”在HTML中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我已经看到了设置表单的action属性的两种方法。 #1。一个空的动作属性: action = pre> #2。使用#的动作属性: $ b action =# 两者之间有什么区别? )解析为基本URL,第二个( 以下内容完全有效: )解析为文档网址。 p $ p> < form action =method =post> < p>< input type =submit/>< / p> < / form> 现在请注意,根据 HTML4规范, action 属性是强制性的,它必须包含有效的URI。但根据 URI RFC ,一个空的URI仍然是一个URI: 尽管它是强制性的,但如果没有指定操作属性,大多数(如果不是所有的话)浏览器都会回发给响应的发起者。 在HTML5中,动作属性不是必需的。来自规格:相关: 对HTML表单的action属性使用空的URL是一种好的做法吗? (action ="") I've seen two methods of setting a form's action attribute.#1. An empty action attribute:action=""#2. Action attribute with #:action="#"What are the differences between the two? 解决方案 The first one ("") resolves to the base URL, and the second one (#) resolves to the document URL.The following is perfectly valid:<form action="" method="post"> <p><input type="submit"/></p></form>Now beware, according to the HTML4 specification, the action attribute is mandatory, and it must contain a valid URI. But according to the URI RFC, an empty URI is still a URI:Although it is mandatory, most if not all browsers will post back to the originator of the response if no action attribute is specified.And in HTML5, the action attribute is not mandatory. From the specs:Related:Is it a good practice to use an empty URL for a HTML form's action attribute? (action="") 这篇关于动作之间的差异=“”和动作=“#”在HTML中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 07:19