JS区分移动端和PC

 

 

1         var ua = navigator.userAgent.toLowerCase();
2         if (ua.match(/MicroMessenger/i) == "micromessenger"
3         || ua.match(/iphone os/i) == "iphone os" || ua.match(/ipad/i) == "ipad"
4         || ua.match(/android/i) == "android" || ua.match(/midp/i) == "midp"
5         || ua.match(/rv:1.2.3.4/i) == "rv:1.2.3.4" || ua.match(/ucweb/i) == "ucweb"
6         || ua.match(/windows ce/i) == "windows ce" || ua.match(/windows mobile/i) == "windows mobile") {
7            alert("移动端");8         }

 

posted @ 2016-11-25 14:30  灰色雨逸  阅读(857)  评论(1编辑  收藏  举报