JS determines whether to browse the page on the mobile terminal

function IsMobile(){
    let info = navigator.userAgent;
    let agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPod", "iPad"];
    for(let i = 0; i < agents.length; i++){
        if(info.indexOf(agents[i]) >= 0) return true;
    }
    return false;
}

 

Guess you like

Origin www.cnblogs.com/yu-shang/p/12749967.html