javascript 判断是否移动客户端 userAgent isMobile

var isMobile = {
            Android: function () {
                return (/android/i.test(navigator.userAgent.toLowerCase()));
            },
            BlackBerry: function () {
                return (/blackberry/i.test(navigator.userAgent.toLowerCase()));
            },
            iOS: function () {
                return (/iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase()));
            },
            iPhone: function () {
                return (/iphone/i.test(navigator.userAgent.toLowerCase()));
            },
            iPad: function () {
                return (/ipad/i.test(navigator.userAgent.toLowerCase()));
            },
            iPod: function () {
                return (/ipod/i.test(navigator.userAgent.toLowerCase()));
            },
            Opera: function () {
                return (/opera mini/i.test(navigator.userAgent.toLowerCase()));
            },
            Windows: function () {
                return (/iemobile/i.test(navigator.userAgent.toLowerCase()));
            },
            any: function () {
                return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
            }
        };

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。