Today I got a feedback from a bug, saying that the function of a page cannot be used. Open the console and found an error: object is not a function.
It feels very strange. Why did this feature suddenly have problems if it has not been moved? All mainstream browsers have been tested when they were launched.
Although strange, it still solves the problem. Looking at the code, I found that the name attribute of a radio object and the function name are duplicated. The code is as follows:
<body> <input type="radio" name="test" onclick="test();"/> <br/> <form action=""> <input type="radio" name="test" onclick="test();"/> </form> </body> <script type="text/javascript"> function test(){ alert("11"); }</script>Modified the function name and solved the problem. But the root cause was not found, because this function name was like this before and could be used normally. Modify the code
onclick="alert(test);"
I found that "object HTMLInputElement" popped up, and the browser parsed the test and became a dom object.
After the script script test function alert(test); is still a function.
Looking at the svn version, I found that when I was doing another function, I added a form form to wrap this radio. Causes a browser parsing error.
Summary: There is no problem with the code without modification. Maybe the changes will cause other problems. Some browser compatibility problems are caused by irregular codes, so you must write codes in the future!
If anyone knows why the form browser has been parsed, can you tell me. Thank you very much!