MENU

js自动判断设备类型

January 27, 2020 • javascript

<script type = "text/javascript" >
    function fBrowserRedirect() {
        var ua = navigator.userAgent.toLowerCase();
        var Android = String(ua.match(/android/i)) == "android";
        var iPad = String(ua.match(/ipad/i)) == "ipad";
        var iPhone = String(ua.match(/iphone/i)) == "iphone";
        if (!Android && !iPad && !iPhone) {
            console.log('非')
        } else {
            console.log('是')
        }
    }
    fBrowserRedirect();
    window.onresize = function() {
        fBrowserRedirect();
        console.log("识别成功");
    } 
</script>
转载请注明出处,并添加原文地址

Archives QR Code Tip
QR Code for this page
Tipping QR Code