Mobile-Touch Events Ontouchstart, Ontouchmove, Ontouchend, Ontouchcancel

Source: Internet
Author: User

Http://www.cnblogs.com/foolisher/p/5412723.html

http://blog.csdn.net/b7995547/article/details/48951761

Http://www.cnblogs.com/koukouyifan/p/4066567.html

CSS Device-width how to get in JS

0,js to determine whether it is a mobile phone or a PC:

function IsPC () {
var useragentinfo = navigator.useragent;
var Agents = ["Android", "IPhone",
"SymbianOS", "Windows Phone",
" IPad", "IPod");
var flag = true;
For (var v = 0; v < agents.length; v++) {
if (Useragentinfo.indexof (Agents[v]) > 0) {
flag = false;
Break ;
}
}
return flag;
}

var flag = IsPC (),//true for PC, false for mobile

1. Introduction to Touch Events

The Web page mouse on the PC generates onmousedown, onmouseup, onmouseout, onmouseover, onmousemove events, but on mobile devices such as iphone, ipod Touch, The Ontouchstart, Ontouchmove, Ontouchend, Ontouchcancel events are generated when the Web page on the ipad touches the screen, corresponding to the touch screen start, drag and finish, and the touch screen event and cancellation. when the finger is pressed, the ontouchstart is triggered;when moving the finger, trigger ontouchmove;triggers the ontouchend when the finger is removed. when some higher-level events occur (such as phone access or pop-up messages), the current touch operation is triggered, triggering ontouchcancel. The game, archive, and so on are usually paused during ontouchcancel.  2. The relationship between touch events and mouse events

After the touch screen operation, the moment the finger is lifted (i.e. after ontouchend), the system will determine whether the content of the element receiving the event has been changed, if the content is changed, the next event will not be triggered, if not changed, will follow the Mousedown,mouseup, The Click order triggers the event. In particular, the Mouseout event of the previous event is triggered only when a touch-screen event is triggered again

Mobile-Touch Events Ontouchstart, Ontouchmove, Ontouchend, Ontouchcancel

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.