版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dengmengxin/article/details/50630571
可能有其它缺陷,不过正常能用
<script type="text/javascript">
function detectMobile() {
return navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i);
}
if (navigator.userAgent.match(/iPad/i)) {
//iPad设备
}
if (detectMobile()) {
//移动设备
}else{
//PC
}
</script>