问题描述
有关于他们的传说。我想知道事情的真相。是什么结果之间的差异<输入类型=提交值='文字'/>
和<按钮式='提交'>文字< /按钮&GT ;
There are many legends about them. I want to know the truth. What is the difference between<input type='submit' value='text' />
and <button type='submit'>text</button>
?
推荐答案
不知道你来自哪里,让你的传说,但是:
Not sure where you get your legends from but:
与
<button type="submit">(html content)</button>
IE6将提交标记之间该按钮的所有文字,其他的浏览器将只提交值。使用&LT;按钮和GT;
你可以对这些按钮的设计更布局的自由度。在其所有意图和目的,它似乎优秀的在第一,但不同的浏览器怪癖使它很难在次使用。
IE6 will submit all text for this button between the tags, other browsers will only submit the value. Using <button>
gives you more layout freedom over the design of the button. In all its intents and purposes, it seemed excellent at first, but various browser quirks make it hard to use at times.
在你的榜样,IE6将文本
发送到服务器,而其他大多数浏览器会发出什么。为了让跨浏览器兼容,使用&LT;按钮式=提交值=文本&gt;文字&LT; /按钮&GT;
。更妙的是:不使用的价值,因为如果添加HTML变得相当棘手的是什么在服务器端接收。相反,如果你必须发送一个额外的价值,使用隐藏域。
In your example, IE6 will send text
to the server, while most other browsers will send nothing. To make it cross-browser compatible, use <button type="submit" value="text">text</button>
. Better yet: don't use the value, because if you add HTML it becomes rather tricky what is received on server side. Instead, if you must send an extra value, use a hidden field.
与
<input type="button" />
在默认情况下,这下不会落空。它甚至不会提交表单。只能放在按钮上的文字和CSS的方式给它一个规模和边界。其原来的(和电流)的意图是无需表单提交给服务器执行脚本。
By default, this does next to nothing. It will not even submit your form. You can only place text on the button and give it a size and a border by means of CSS. Its original (and current) intent was to execute a script without the need to submit the form to the server.
与
<input type="submit" />
像前,但实际上提交周围的表单。
Like the former, but actually submits the surrounding form.
与
<input type="image" />
像前(提交),它也将提交表单,但你可以使用任何图像。这曾经是使用图像作为按钮,当需要的表单提交preferred方式。为了加强控制,&LT;按钮和GT;
现在使用。这也可以用于的服务器端影像地图的,但是这是一个罕见的这些日子。当您使用 USEMAP
-attribute和(有或没有该属性),浏览器将发送鼠标指针X / Y坐标到服务器(更多precisely ,当下的按钮内部的鼠标指针位置单击时)。如果你只是忽略了这些额外,它只不过是伪装成图像的提交按钮了。
Like the former (submit), it will also submit a form, but you can use any image. This used to be the preferred way to use images as buttons when a form needed submitting. For more control, <button>
is now used. This can also be used for server side image maps but that's a rarity these days. When you use the usemap
-attribute and (with or without that attribute), the browser will send the mouse-pointer X/Y coordinates to the server (more precisely, the mouse-pointer location inside the button of the moment you click it). If you just ignore these extras, it is nothing more than a submit button disguised as an image.
有浏览器之间有一些细微的差别,但都将提交的价值属性,除了&LT;按钮方式&gt;
标记如上所述
There are some subtle differences between browsers, but all will submit the value-attribute, except for the <button>
tag as explained above.
这篇关于℃之间的差异;输入类型=“提交”/&GT;和&lt;按钮式=“提交”&gt;文字&LT; /按钮&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!