<script>
//判断访问设备,方便后面针对不同设备调用代码
var dev = "";
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
//设备为移动端
dev = "mobile";
}
else {
//设备为pc
dev = "pc";
}
console.log("当前使用设备为:" + dev);
</script>
http://blog.csdn.net/kongjiea/article/details/17612899