JavaScript 判斷是PC端仍是移動端

function IsPC() {php

    var userAgentInfo = navigator.userAgent;spa

    var Agents = ["Android", "iPhone",code

                "SymbianOS", "Windows Phone",string

                "iPad", "iPod"];io

    var flag = true;function

    for (var v = 0; v < Agents.length; v++) {class

        if (userAgentInfo.indexOf(Agents[v]) > 0) {word

            flag = false;vi

            break;co

        }

    }

    return flag;

}

相關文章
相關標籤/搜索