判斷是不是手機訪問

<!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>css

相關文章
相關標籤/搜索