[Go]html page Call js file function error onclick is not defined processing method

Source: Internet
Author: User

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
    1. <input type="button" value="Login Now" onclick="Dosave ();" />

Js:

[JavaScript]View plain copy
    1. Dosave = function () {
    2. Alert ("Success!")  ");
    3. }

The following two types of errors are generally fatal:

[JavaScript]View plain copy
    1. function Dosave () {
    2. Alert ("will error!!  ");
    3. }

And

[JavaScript]View plain copy
    1. var Dosave = function () {
    2. Alert ("will error!!  ");
    3. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.