zoukankan      html  css  js  c++  java
  • js判断是安卓还是Ios

    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    </head>

    <body>
    <button id='btn' onclick="test()">点击</button>
    </body>

    </html>
    <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终端
    function test() {
    if (isAndroid == true) {
    location.href = "http://uri6.com/tkio/3aEfmya"
    console.log("安卓手机")
    } else {
    location.href = "http://uri6.com/tkio/MBFbAva"
    console.log("苹果手机")
    }
    }
    </script>
  • 相关阅读:
    canvas之碎碎念
    canvas之动态时钟
    属性小问题
    readonly and disabled
    table
    地图热区
    子块元素在父块元素中居中
    Ajax与JS
    前端测试
    html5/css3
  • 原文地址:https://www.cnblogs.com/ylblogs/p/11052100.html
Copyright © 2011-2022 走看看