One of the magical questions that I stumbled into today in the project is hereby recorded.
First we look at the following code, the test page can look here, the function and logic of the page is very simple.
This code is logically free of errors and bugs that can theoretically be fully implemented.
<body>
<script language= " JavaScript
Function Dosubmit ()
{
var theform = document.getElementById (' theform ');
theform.submit ();
}
</script>
<form method= "POST" id= "Theform"
<table width= ","
<tr>
<td><input type= "text" value= "test" ></TD>
</tr>
< Tr>
<td> <input type= "button" name= "Submit" value= "submitted" onclick= "DosUbmit () "></td>
</tr>
</table>
</form>
</body>
If you use Firefox to view this page and click the Submit button, the form will be submitted normally, but we switch to ie below, IE will prompt "object does not support this property and methods" and stop the commit operation.
What the hell is going on here? After my many search data, found that the submit button Name= "Submit" properties in trouble.
At this time we will Theform.submit (), comment out, a new line of input alert (theform.submit.value), refresh the page and then click Submit Again, pop-up window will show "submit" two words, magic! Theform.submit is actually a submit button instead of a theform Method!
Why this problem occurs, because in IE can be through the form. Form element name This way you get all the form elements under a form, but here's how it happens. If the name of a form element is the same as the form's method name, then IE will first resolve the name to a FORM element. Instead of a form method, this is a magical problem.