zoukankan      html  css  js  c++  java
  • 移动端与PC端的触屏事件

    由于移动端是触摸事件,所以要用到H5的属性touchstart/touchmove/touched,但是PC端只支持鼠标事件,所以此时可以这样转换
    
    var touchEvents = {
            touchstart:"touchstart",
            touchmove:"touchmove",
            touchend:"touchend",
            initTouchEvents:function () {
           var self = this;
    if (self.isPC()) { self.touchstart = "mousedown"; self.touchmove = "mousemove"; self.touchend = "mouseup"; } },
         isPC:function(){ //判断pc端与移动端
               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]) != -1) { flag = false; break; }  
               }  
               return flag;   //true为pc端,false为非pc端
         }
        };
  • 相关阅读:
    POJ 最小球覆盖 模拟退火
    POJ 1379 模拟退火
    PythonTip(2)
    PythonTip(1)
    LA 3353 最优巴士线路设计
    LA 4254 贪心
    判断分析
    因子分析——因子得分
    因子分析——应用
    因子分析——因子旋转
  • 原文地址:https://www.cnblogs.com/laoniaofly/p/5927936.html
Copyright © 2011-2022 走看看