JavaScript programming Start (Lesson six) _ Basics

Source: Internet
Author: User
MouseDown Events and MouseUp events


As you know, the combination of the MouseDown event and the MouseUp event is the Click event, but if you press the mouse on the link and move outside the link to release the mouse, then only the moused

The own incident. These two events can increase the image effect of the icon button,
As for the properties of MouseDown and MouseUp, they are accompanied by the Click event, which is the same mechanism that the KeyPress event is a combination of KeyDown events and KeyUp events.

, these 3 mouse events also have modifier properties.
(Note: If you use the return statement in onclick event handling, it can receive any numeric value.) As long as the value is not false, the browser can complete the commit. But if you browse

The form submission operation is canceled if the value of the device is false. )

Click events and Dbclick Events
OnClick is the click of an event, OnDblClick is a double-click event, and in fact it is difficult to distinguish between consecutive clicks and double-clicks. They can interfere with each other. And in IE and other browsers, there are

Different. In some browsers, the Click event triggers every click of the event, and in IE, only the first click of the double-click event triggers the Click event. No matter what, click the Thing

The pieces are not automatically canceled or ignored. Therefore, if you want to trigger two completely different procedures when you click and double-click a link, you must programmatically delay the click action to know that the double

Click.

Cases:
<script>
var timer=null;
Document.onclick=new Function ("Timer=settimeout (click,500)")
Document.ondblclick=new Function ("cleartimeout (timer);d Blclick ()")
function Click () {
Alert ("click")
}
function DblClick () {
Alert ("DblClick")
}
</script>

In a newer browser, both of the linked event handlers monitor the special behavior that makes the script block links.
For example, if you want to navigate to another page before you do some data entry confirmation, if some fields are not filled out correctly, you can remind and terminate the link. To achieve this validation, you must

The event handler returns TRUE or FALSE to the last statement or event handler itself. If you return false, the link is terminated.

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.