相关疑难解决方法(0)

检测移动设备

我有一个Javascript代码,我检测我的网站是否是从移动设备上查看的.以下是我的代码:

(function() {
    if (navigator.userAgent.match(/Android/i)
            || navigator.userAgent.match(/webOS/i)
            || navigator.userAgent.match(/iPhone/i)
            || navigator.userAgent.match(/iPad/i)
            || navigator.userAgent.match(/iPod/i)
            || navigator.userAgent.match(/BlackBerry/i)
            || navigator.userAgent.match(/Windows Phone/i)
            || navigator.userAgent.match(/Opera Mini/i)
            || navigator.userAgent.match(/IEMobile/i)
            ) {
        isMobile = true;
    }
})();
Run Code Online (Sandbox Code Playgroud)

此代码是否涵盖所有可能的情况,或者某些设备是否有可能绕过此检查?

javascript mobile detection

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

detection ×1

javascript ×1

mobile ×1