js判断设备是移动端还是pc端

function isPc(){
    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) ){
        console.log('移动端');
    }else{
        console.log('pc端');               
    }
}
isPc();

 

posted @ 2017-07-10 10:39  超拉风の小见见  阅读(1701)  评论(0编辑  收藏  举报