zoukankan      html  css  js  c++  java
  • js 判断android、IOS

    var ua = navigator.userAgent.toLowerCase();    
        if (/iphone|ipad|ipod/.test(ua)) {
                //alert("iphone");        
        } else if (/android/.test(ua)) {
                alert("android");    
        }
    <script type="text/javascript">
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    alert('是否是Android:'+isAndroid);
    alert('是否是iOS:'+isiOS);
    </script>
    if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
        //alert(navigator.userAgent);  
        window.location.href ="iPhone.html";
    } else if (/(Android)/i.test(navigator.userAgent)) {
        //alert(navigator.userAgent); 
        window.location.href ="Android.html";
    } else {
        window.location.href ="pc.html";
    };
  • 相关阅读:
    2021.1.11
    2021.1.10(每周总结)
    2021.1.9
    2021.1.8
    2021.1.7
    构建之法阅读笔记01
    [java] XML DTD XSD
    详解 泛型 与 自动拆装箱
    详解 正则表达式
    详解 LinkedHashMap
  • 原文地址:https://www.cnblogs.com/chaser-li/p/7794369.html
Copyright © 2011-2022 走看看