About JS's addeventlistener and some common events

Source: Internet
Author: User

function true)

The last parameter in the AddEventListener determines the order in which the event responds;


If true, the event is executed in the order of AddEventListener----The onclick event of the label----Document.onclick

If the order of the event is false for the OnClick event of the label----Document.onclick----AddEventListener

Mouse events

Document.addeventlistener (' MouseDown ', MouseDown); Document.addeventlistener (' click ', MouseClick); Document.addeventlistener (' MouseUp ', MouseUp);


Touch events

Document.addeventlistener (' Touchstart ', Touchstart);d ocument.addeventlistener (' touchend ', Touchend) ;       Touchstart event: Triggers when the finger touches the screen, even if there is already a finger on the screen that triggers the       //Touchmove event: A continuous trigger when the finger is sliding on the screen. During this event, the call to the Preventdefault () event can block       the scrolling//Touchend event: triggered when the finger is left on the screen.       //Touchcancel event: triggered when the system stops tracking touch. The exact departure time for this event is not specified in the documentation, but to guess
(The performance on an iOS device is a call to automatically end the Touchstart event after a period of time)

Each touch event comes with three properties     touches: An array of touch objects that represent the touching operations that are currently being traced.       targettouches: An array of touch objects that are specific to the event target. Changetouches: Represents the array of touch objects that have changed since the last touch                     each touches comes with         ClientX: Touch the x-coordinate of the target in the viewport.         ClientY: Touch the y-coordinate of the target in the viewport.         identifier: Identifies the unique ID of the touch.         PageX: Touch the x-coordinate of the target in the page.         Pagey: Touch the y-coordinate of the target in the page.         ScreenX: Touch the x-coordinate of the target in the screen.         ScreenY: Touch the y-coordinate of the target in the screen. Target         : Touch destination DOM node destination

Support:

WebKit browser in iOS version safari, Android version WebKit, bada version dolfin, BlackBerry 10.1+ in os6+, Opera Mobile Phantom and LG Proprietary OS. Currently only the iOS version of Safari supports multi-touch. PC version of Firefox 6+ and Chrome also supports touch events

code Example 1

var gotouch=function() {       alert (' Touchstartok ');} Document.addeventlistener ("Touchstart", Gotouch);



public override function AddEventListener (
Type:string,
Listener:function,
Usecapture:boolean = False,
Priority:int = 0,
Useweakreference:boolean = False
): void



code Example 2

function Go () {   //...     }
false );

// or listener is directly a function .
function false );
document.getElementById ("Testbutton"). RemoveEventListener ("click", Go); // Delete listener events

About JS's addeventlistener and some common 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.