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