Original address: http://blog.csdn.net/ywl570717586/article/details/53130863
There is always an error in handling the onclick function in the HTML tag today: uncaught Referenceerror:dosave is not defined (...)
Looking for a long while did not find the wrong, and finally found that I was wrong, the correct wording as follows:
Html:
[HTML]View plain copy
- <input type="button" value="Login Now" onclick="Dosave ();" />
Js:
[JavaScript]View plain copy
- Dosave = function () {
- Alert ("Success!") ");
- }
The following two types of errors are generally fatal:
[JavaScript]View plain copy
- function Dosave () {
- Alert ("will error!! ");
- }
And
[JavaScript]View plain copy
- var Dosave = function () {
- Alert ("will error!! ");
- }
Why is this, because:
The HTML page calls the function in the JS file, which must be in the form of Dosave = function () {}, otherwise written, and the HTML page will not search for the function.
[Go]html page Call js file function error onclick is not defined processing method