首页 > 代码库 > 判断是否是手机访问
判断是否是手机访问
<!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>
判断是否是手机访问