判断是否是手机访问

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>判断是否是手机访问-jq22.com</title>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<p><label>js判断结果:</label><span id="rs_js" class="red"></span></p><script>
if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || /Android/i.test(navigator.userAgent) || /BlackBerry/i.test(navigator.userAgent) || /IEMobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) {
if (/iPad/i.test(navigator.userAgent)) {
$("#rs_js").text("iPad平板");
} else {
$("#rs_js").text("手机");
}
} else {
$("#rs_js").text("电脑");
}</script>
</body>
</html>

posted @ 2017-07-25 14:22  可苦可乐8  阅读(93)  评论(0编辑  收藏  举报