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

  • 相关阅读:
    2021.06.19 DP-方格取数 + 花店橱窗布置
    2021.06.15 DP-编辑距离
    2021.06.12模拟总结
    2021.6.8 背包模拟 总结
    20210529-背包
    lnmp环境中的:supervisorctl
    python常用语法合集
    python 常用数据结构
    DVWA环境
    mysql中each( use () {})
  • 原文地址:https://www.cnblogs.com/isdom/p/webclips043.html
Copyright © 2011-2022 走看看