Some questions about the "HTML" button buttons

Source: Internet
Author: User
Tags button type

Problem:

button buttons do not function the same in different browsers when the Type property is not set. As an example:

Html:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8"/>    <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge,chrome=1"/>    <Metaname= "Renderer"content= "WebKit"/>    <Metaname= "keywords"content=""/>    <Metaname= "description"content=""/>    <title>Some issues with button buttons</title></Head><Body>    <formAction= "result.php"Method= "POST">        <inputtype= "text"name= "txt"placeholder= "Enter whatever you want!" "AutoComplete= "Off"/>        <Button>button click Submit</Button>    </form></Body></HTML>

result.php:

Echo $_post [' txt ']?>

We found that the IE8 above including the IE8 click button can submit the form normally, but under IE6 and IE7, clicking the button does not respond.

Reason:

Why is there a difference? Because button buttons do not have the Type property set, the type of the button is parsed differently in different browsers.

With W3school you can see that we need to always specify the Type property for button buttons. The default type of Internet Explorer (tested IE6 and IE7) is "button", while the default value in other browsers (including the Web specification) is "submit". specific content points to this understanding .

Finally we modified the demo:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8"/>    <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge,chrome=1"/>    <Metaname= "Renderer"content= "WebKit"/>    <Metaname= "keywords"content=""/>    <Metaname= "description"content=""/>    <title>Some issues with button buttons</title></Head><Body>    <formAction= "result.php"Method= "POST">        <inputtype= "text"name= "txt"placeholder= "Enter whatever you want!" "AutoComplete= "Off"/>        <Buttontype= "button">Button buttons Type</Button>        <Buttontype= "Submit">Button type is submit</Button>    </form></Body></HTML>

Ps:

The purpose of writing this article is to remind yourself that you need to specify the appropriate type for the tag when using the button.

Some questions about the "HTML" button buttons

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.