JavaScript event summary and javascript Summary

Source: Internet
Author: User

JavaScript event summary and javascript Summary

The DOM mechanism has been introduced in the previous article. It is mainly designed for the structure and style of web pages. However, a good interface design is not enough, and the interaction between webpages and users needs to be realized. Our ultimate goal is to serve users, so we need users to visit and ask for operations on Web pages. This involves another concept: events.

JavaScript events are column operations caused by users accessing Web pages, such as clicking. The code is executed only after the user executes an operation. The main content of this part is as follows:

 

In the event model, the inline model is the most traditional processing method. As an attribute of HTML tags, the event processing function Processes specified events. Generally, it is mixed with HTML, for example:

 

<Input type = "button" value = "button" onclick = "alert ('wang ');"/>

The script model can separate the HTML and JavaScript code layers, for example:

HTML section:

<Input type = "button" value = "button"/>

JavaScript section:

        var input=document.getElementsByTagName('input')[0];        input.onclick=function(){           alert('wang');        }

Although the script model achieves the separation of HTML and JavaScript, this model also has many problems as we increase the number of times and complexity, event coverage, readability, and this transfer among other issues.

In this case, the DOM2 model is used, and type 2 in the processing function is mainly used for this model. Any model requires the use of event processing functions to bind user operations and code. Generally, the events involved are the mouse and keyboard. You can submit your own requirements through the mouse and keyboard operations, the operation is performed based on the content of the object obtained through the event processing function to obtain the content required by the user.

By processing these events, you can process user operations and obtain the information you need. This part of implementation truly achieves interaction with users. In this process, we need to pay attention to the following problems: browser compatibility. For different browsers and different versions of the same browser, we need to set compatibility, this is also why type 2 in the processing function is divided into W3C and IE.

 

Summary:

A website that can be liked by users is essential to its good interface design and functions. This is the uidesign we have been in contact. Therefore, although the event is mostly used to implement a function and obtain the information required by the user, it must also be fully considered. When obtaining the required information as much as possible, it gives users a comfortable experience. You still need to continue learning this part...

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.