예 1. 누락 된 요점의 단순하고 조잡한 판단
<script type = "text/javaScript"> var suseragent = navigator.useragent.tolowercase (); var bisipad = suseragent.match (/iPad/i) == "iPad"; var bisiphoneos = suseragent.match (/ii) == "iPhone OS"; var bismidp = suseragent.match (/midp/i) == "midp"; var bisuc7 = suseragent.match (/rv:1.2.3.4/i) == "rv : 1.2.3.4"; var bisuc = suseragent.match (/ucweb/i) == "ucweb"; var bisandroid = suseragent.match (/android/i) == "Android"; var bisce = suseragent.match (/windows ce/i) == "Windows CE"; var biswm = suseragent.match (/windows mobile/i) == "Windows Mobile"; if (bisipad || bisiphoneos || bismidp || bisuc7 || bisuc || bisandroid || biscce || biswm) {window.location.href = "3g.php"; } </스크립트>예 2 : 코드가 깔끔하고 많은 기능 이이 추가 된 기능을 기반으로합니다.
<cript> var pc_style = ""var 브라우저 = {버전 : function () {var u = navigator.useragent, app = navigator.appversion; return {trident : u.indexof ( 'trident')> -1, presto : u.indexof ( 'presto')> -1, webkit : u.indexof u.indexof ( 'gecko')> -1 && u.indexof ( 'khtml') == -1, mobile : !! u.match (/applewebkit.* mobile.*/) || !! U.Match (/AppleWebKit/) && u.indexof ( 'Qihu') && u.indexof ( 'Qihu')> -1 && u.indexof ( 'chrome') <0, ios : !! U.match (// (i [^;]+; (u;)? cpu.+mac os x/), and indexof ( 'android ('android ')>. U.indexof ( 'linux')> -1, iPhone : u.indexof ( 'iPhone')> -1 || -1, iPad : u.indexof ( 'iPad'), webapp : u.indexof ( 'safari') == -1, ua : u} () navigator.language) .tolowercase ()} if (browser.versions.mobile &&! browser.versions.ipad) {this.location = "점프 마이크로 스테이션의 홈페이지 주소를 입력하십시오";} </script>예 3 : 일부 기능이 추가되었습니다
<!-스마트 폰 판단 시작-> <!-<script type = "text/javaScript"언어 = "javaScript"> function.prototype.bind = function (bindobj, args) {var _self = this; return function () {return _self.apply (bindobj, [] .concat (args)}}}; document.getElementById (id) : id;}; var 브라우저 = {버전 : function () {var u = navigator.useragent, app = navigator.appversion; return {trident : u.indexof ( 'trident')> -1, presto : u.indexof ( 'presto')> webkit : u.indexof ( ''). -1, gecko : u.indexof ( 'gecko')> -1 && u.indexof ( 'khtml') == -1, mobile : !! u.match (/applewebkit.* mobile.*/) || !! U.Match (/AppleWebKit/), iOS : !! U.match (// (i [^;]+; (u;)? cpu.+mac os x/), android : u.indexof ( 'android')> -1 || u.indexof ( 'linux')> -1, iPhone : u.indexof ( 'iPhone')> -1 | U.indexof ( 'iPad')> -1, webapp : u.indexof ( 'safari') == -1, qqbrw : u.indexof ( 'mqqbrowser')> -1, uclowend : u.indexof ( 'ucweb7.')> -1, ucspecial : u.indexof ( 'rv : 1.4'). {try {return parsefloat (u.match (/ucweb/d+/./d+/gi) .toString (). match (// d+/./d+/). toString ())> = 8.2} catch (e) {if (u.indexof ( 'uc')> -1) {return}}} (returny;}) U.indexof ( 'Symbian')> -1, ucsb : u.indexof ( 'firefox/1.')> -1} ()}} var _gaq = _gaq | []; rf.tolocalelowscase (). indexof ( ". xiu.com") === -1) {var defaultJumpdomain = "" "; if (defaultJumpDomain =="www ") {return;} if (defaultJumpDomain =="m ") {window.location.href = "http://wap.xiu.com/?from=pc"; return; }if (screen == undefined || screen.width <810) {if (browser.versions.ipad == true) {return;} if (browser.versions.webkit == true || browser.mobile == true || brower.iOs.iOs.iOs.iOs.iOs.iOs.iOs.iOs.iOs.iOs. Browser.iphone == true || versions.ucweb == true || "http://wap.xiu.com/";}} }) (Window, 브라우저);예 4 : 간단한 wulin.com을 사용하는 것이 좋습니다. 더 나은 코드가 있으면 공유 할 수 있습니다.
<script type = "text/javaScript"> var browser = {버전 : function () {var u = navigator.useragent, app = navigator.appversion; return {trident : u.indexof ( 'trident')> -1, presto : u.indexof ( 'presto'), webkit : u.indexof ( 'aplewewee). u.indexof ( 'gecko')> -1 && u.indexof ( 'khtml') == -1, mobile : !! u.match (/applewebkit.* mobile.*/) || !! U.Match (/AppleWebKit/), iOS : !! U.match (// (i [^;]+; (u;)? cpu.+mac os x/), android : u.indexof ( 'android')> -1 || u.indexof ( 'linux')> -1, iPhone : u.indexof ( 'iPhone')> -1 | u.indexof ( 'iPad')> -1, webapp : u.indexof ( 'safari') == -1, qqbrw : u.indexof ( 'mqqbrowser')> -1, weixin : u.indexof ( 'micromessenger')> -1, uclowend : u.indexof ( 'ucweb7.')). u.indexof ( 'rv : 1.2.3.4')> -1, ucweb : function () {try {return parsefloat (u.match (/ucweb/d+/./d+/gi) .tostring (). -1) {return true;} else {return false;}}} (), symbian : u.indexof ( 'symbian')> -1, ucsb : u.indexof ( 'firefox/1.')> -1};} (), liulanqi : navigator.useragent} if (browser.quger.qqbrw). 브라우저 ");} else {docum