zoukankan      html  css  js  c++  java
  • zepto点击事件兼容pc和mobile

    判断pc还是mobile,重写click事件

    var CLICK='click';
    (function browserRedirect() {
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
        var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
        var bIsMidp = sUserAgent.match(/midp/i) == "midp";
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
        var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
        var bIsAndroid = sUserAgent.match(/android/i) == "android";
        var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
        var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
        if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){
           CLICK='tap';
            alert("iphone");
        }else{
            alert("pc")
        }
    }());
    

      使用:

    function clicktabs(tit_id, box_id, cur) {
        var g_tags = $(tit_id),
                g_conts = $(box_id),
                g_current = cur;
    
        g_tags[CLICK](function(){
            
        })
    }
    

      

  • 相关阅读:
    Linux上安装软件
    VIM的使用
    Linux命令(系统管理)
    django潜心之路4--模型
    django潜行之路3-模板
    django潜行之路2---视图
    django潜行之路1
    sql基础
    Mysql数据库总结
    反爬虫机制
  • 原文地址:https://www.cnblogs.com/xupeiyu/p/5067038.html
Copyright © 2011-2022 走看看