JS 判断用户设备 移动端或桌面端

if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) ) { 
    alert("Mobile");
}
else {
    alert("Desktop");
}

 

posted @ 2019-05-31 11:49  Ryan_zheng  阅读(732)  评论(0编辑  收藏  举报