标签:touch 实例 als htm new 回调 简单 hone array
判断移动端还是pc端functionIsPC()
{ var userAgentInfo = navigator.userAgent; var Agents = new Array("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; } $(document).bind(touchEvents.touchstart, function (event) {
event.preventDefault(); });<br>$(document).bind(touchEvents.touchmove, function (event) { event.preventDefault(); });$(document).bind(touchEvents.touchend, function (event) { event.preventDefault(); });var touchEvents = {
touchstart: "touchstart",
touchmove: "touchmove",
touchend: "touchend",
/**
* @desc:判断是否pc设备,若是pc,需要更改touch事件为鼠标事件,否则默认触摸事件
*/
initTouchEvents: function () {
if (isPC()) {
this.touchstart = "mousedown";
this.touchmove = "mousemove";
this.touchend = "mouseup";
}
}
};
标签:touch 实例 als htm new 回调 简单 hone array
原文地址:http://www.cnblogs.com/yzmzy/p/7228119.html