zoukankan      html  css  js  c++  java
  • js判断设备类型

    1.检测安卓,苹果和windows phone的手机

    var ua = navigator.userAgent;
    var url;

    if(ua.match(/WindowssPhone/i) !=null){
        console.log('this is Windowsphone ');
    }
    else if(ua.match(/iPhone|iPod/i) != null){
        url = "itms-apps://itunes.apple.com/app/id959587493";
        window.setTimeout(function () {
            window.location.href = url;
        },10);
    }
    else if(ua.match(/Android/i) != null){
        url = "http://a.app.qq.com/o/simple.jsp?pkgname=com.electric.chargingpile";
        window.setTimeout(function () {
            window.location.href = url;
        },10);
    }

    var ua = navigator.userAgent;
            var url;

            if(ua.match(/WindowssPhone/i) !=null){
                console.log('this is Windowsphone ');
            }
            else if(ua.match(/iPhone|iPod/i) != null){
                url = "itms-apps://itunes.apple.com/app/id959587493";
                window.setTimeout(function () {
                    window.location.href = url;
                },10);
            }
            else if(ua.match(/Android/i) != null){
                url = "http://a.app.qq.com/o/simple.jsp?pkgname=com.electric.chargingpile";
                window.setTimeout(function () {
                    window.location.href = url;
                },10);
            }

    判断设备为微信内的浏览器

    2.if ((/MicroMessenger/i).test(window.navigator.userAgent)) {}

  • 相关阅读:
    关于unsigned char的取反操作
    Windows10 添加永久路由
    mysql入门-触发器
    mysql入门-视图
    Mysql入门-索引
    Mysql入门-表操作
    mysql数据类型选取
    MQ-基本操作
    关于Hadoop集群的配置方法——另附安装网址
    关于——This is probably not a problem with npm. There is likely additional logging output above.——的解决方法
  • 原文地址:https://www.cnblogs.com/isdom/p/webclips043.html
Copyright © 2011-2022 走看看