判斷移動端設備: navigator.userAgent.toLowerCase()


判斷你的瀏覽設備: navigator.userAgent.toLowerCase(); (返回當前用戶所使用的是什么瀏覽器,將獲得的信息變成小寫)

function browserRedirect() {
            var _devices= navigator.userAgent.toLowerCase();
            var bIsIpad = _devices.match(/ipad/i) == "ipad";
            var bIsIphoneOs = _devices.match(/iphone os/i) == "iphone os";
            var bIsMidp = _devices.match(/midp/i) == "midp";
            var bIsUc7 = _devices.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
            var bIsUc = _devices.match(/ucweb/i) == "ucweb";
            var bIsAndroid = _devices.match(/android/i) == "android";
            var bIsCE = _devices.match(/windows ce/i) == "windows ce";
            var bIsWM = _devices.match(/windows mobile/i) == "windows mobile";
            document.writeln("您的瀏覽設備為:");
            if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
                // document.writeln("phone");
                //  移動設備顯示狀態
            } else {
              //  pc設備顯示狀態
            }
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM