通过JS语句判断WEB网站的访问端是电脑还是手机

2025-04-02 04:17:57
推荐回答(1个)
回答1:

function IsPc() {
    var agentInfo = navigator.userAgent.toLowerCase();
    var Agents = ["android", "iphone",
        "symbianos", "windows phone",
        "ipad", "ipod",
        "midp","windows ce",
        "ucweb","rv:1.2.3.4"];
    for (var i = 0; i < Agents.length; i++) {
        if (agentInfo.indexOf(Agents[i]) > 0) {
            return false;
        }
    }
    return true;
}