A BUG was reported today, saying that a function on a page cannot be used. Open the console and find an error: object is not a function.
It feels very strange. This function has not been touched recently, so why does it suddenly cause problems? All major browsers were tested when it went online.
Although it is strange, it still solves the problem. Looking at the code, I found that the name attribute of a radio object has the same name as a function name. 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 the function name was like this before and could be used normally. Modify code
onclick="alert(test);"
I found that "object HTMLInputElement" popped up, and the browser parsed the test into a dom object.
After the script test function alert(test); is still a function.
Looking at the svn version, I found that I added a form to wrap up the radio when I was doing another function. This causes browser parsing errors.
Summary: The code that has not been changed may not be a problem. Maybe the changes have caused other problems. Some browser compatibility issues are caused by code irregularities. You must write code in a standardized manner in the future!
If any expert knows why browser parsing problem occurs after adding form, can you tell me. Thank you so much!