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)) {}

  • 相关阅读:
    读《阿里云是如何失控的》有感
    LeetCode Search in Rotated Sorted Array 在旋转了的数组中查找
    界面编程模仿篇(QQ登录界面逼真篇)
    最牛B的编码套路
    QinQ封装及终结详解
    seaJs学习笔记之javascript的依赖问题
    Deploy maven on Linux OS
    c++——inline内联函数
    c++——引用
    c++——const关键字
  • 原文地址:https://www.cnblogs.com/isdom/p/webclips043.html
Copyright © 2011-2022 走看看