判断是手机还是PC端

 1 function IsPC() {
 2    var userAgentInfo = navigator.userAgent;
 3    var Agents = ["Android", "iPhone",
 4       "SymbianOS", "Windows Phone",
 5       "iPad", "iPod"];
 6    var flag = true;
 7    for (var v = 0; v < Agents.length; v++) {
 8       if (userAgentInfo.indexOf(Agents[v]) > 0) {
 9          flag = false;
10          break;
11       }
12    }
13    return flag;
14 }

 

posted @ 2016-08-09 16:38  大米1989  阅读(178)  评论(0编辑  收藏  举报