且构网

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

℃之间的差异;输入类型=“提交”/>和<按钮式=“提交”>文字< /按钮>

更新时间:2022-11-30 10:52:32

不知道你来自哪里,让你的传说,但是:

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.