Summary of JavaScript events

Source: Internet
Author: User

The previous chapter has introduced the DOM mechanism, mainly for the design of Web page structure and style. But with a good interface design is not enough, but also need to implement the Web page and user interaction. Our ultimate goal is to serve our users, so we need users to access and manipulate Web pages. This involves another concept: events.

JavaScript events are some of the column operations that are caused by users accessing Web pages, such as user clicks. The corresponding code is executed only after the user has performed an action. The main contents of this section are as follows:

In the event model, the inline model is the most traditional processing method, and the event handler functions as an attribute of the HTML tag to handle the specified event, which is typically mixed with HTML, for example:

<input type= "button" value= "pushbutton"  onclick= "alert (' Wang ');"/>

The scripting model can then implement the separation of HTML from the JavaScript code layer, for example:

HTML section:

<input type= "button" value= "buttons"/>

JavaScript section:

        var input=document.getelementsbytagname (' input ') [0];        Input.onclick=function () {           alert (' Wang ');        }

While the scripting model implements the separation of HTML from JavaScript, there are many problems with the number of times and complexity of the model, including the problem of coverage, readability, and this delivery.

In this case, the DOM2 model is used, and type 2 in the processing function is mainly used for the model. Regardless of the model, you need to use event handlers to implement the binding between the user operation and the code, usually involving the mouse and keyboard, the user through the mouse and keyboard operation class to submit their own needs, and the operation is based on the event handler function obtained by the object contained in the processing of the content, Get the content that the user needs.

Through these event processing, the user's actions can be processed to get the information that the user needs. This part of the implementation, only to truly realize the interaction with the user. In this process, we need to pay attention to the main issues are: Browser compatibility issues, for different browsers and different versions of the same browser, we need to make compatibility settings, which is why the processing function of type 2 is divided into the web and IE.

Summarize:

A user favorite site, its good interface design and functionality is essential, which is what we have been in touch with the UI design. So, although the event is more to achieve a certain function, to get the information that the user needs, but also must be thoughtful, as far as possible to obtain the required information, can give the user a comfortable experience. This part of the study also needs to continue ...

Summary of JavaScript events

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.