凌的博客

您现在的位置是: 首页 > 前端学习 > Js > 

Js

js判断是否是手机端

2016-04-28 Js 803
//手机 function IsMobile() { var userAgentInfo = navigator.userAgent; var Agents = [\"Android\", \"iPhone\", \"SymbianOS\", \"Windows Phone\", \"iPad\", \"iPod\"]; var vIs = false; for (var i =
//手机
function IsMobile() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
    var vIs = false;
    for (var i = 0; i < Agents.length; i++) {
        if (userAgentInfo.indexOf(Agents[i]) > 0) {
            vIs = true;
            break;
        }
    }
    return vIs;
}

文章评论

0条评论