ตัวอย่าง 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 || bisce || biswm) {window.location.href = "3g.php"; } </script>ตัวอย่างที่ 2: รหัสนั้นเรียบร้อยและฟังก์ชั่นจำนวนมากขึ้นอยู่กับฟังก์ชั่นที่เพิ่มเข้ามานี้
<script> var pc_style = "" var browser = {เวอร์ชัน: function () {var u = navigator.useragent, app = navigator.appversion; return {trident: u.indexof ('trident')> -1, presto: u.indexof ('presto') u.indexof ('gecko')> -1 && u.indexof ('khtml') == -1, มือถือ: !! u.match (/applewebkit.*mobile.*/) || !! u.match (/applewebkit/) && u.indexof ('qihu') && u.indexof ('qihu')> -1 && u.indexof ('chrome') <0, ios: !! u.match (// (i [^;]+; (u;)? U.Indexof ('Linux')> -1, iPhone: U.Indexof ('iPhone')> -1 || U.Indexof ('Mac')> -1, iPad: U.Indexof ('iPad')> -1, 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" language = "javascript"> function.prototype.bind = ฟังก์ชั่น (bindobj, args) {var _self = this; return function () {return _self.aply.apply (bindobj, [] document.getElementById (id): id;}; var browser = {เวอร์ชัน: function () {var u = navigator.useragent, app = navigator.appversion; return {trident: u.indexof ('trident')> -1, presto: u.indexof (' u.indexof ('gecko')> -1 && u.indexof ('khtml') == -1, มือถือ: !! u.match (/applewebkit.*mobile.*/) || !! u.match (/applewebkit/), ios: !! u.match (// (i [^;]+; (u;)? cpu.+mac os x/), Android: u.indexof ('Android')> -1 || u.indexof ('linux') U.Indexof ('iPad')> -1, WebApp: U.Indexof ('Safari') == -1, qqbrw: U.Indexof ('mqqBrowser')> -1, UClowend: U.Indexof ('Ucweb7.')> -1, UcSpecial: U.Indexof ( {return parsefloat (u.match (/ucweb/d+/./d+/gi) .toString (). การจับคู่ (// d+/./d+/). toString ())> = 8.2} catch (e) {ถ้า (u.indexof ('uc')> -1) U.Indexof ('Symbian')> -1, UCSB: U.Indexof ('Firefox/1.')> -1};} ()} var _gaq = _gaq || rf.tolocalelowercase (). indexof (". xiu.com") === -1) {var defaultjumpdomain = ""; ถ้า (defaultjumpdomain == "www") {return;} ถ้า (defaultjumpdomain == "m") (หน้าจอ == undefined || screen.width <810) {if (browser.versions.ipad == true) {return;} if (browser.versions.webkit == true || browser.versions.mobile == True browser.versions.ucspecial == true) {win.location.href = "http://wap.xiu.com/?from=pc"; </script>-> <!-การตัดสินของสมาร์ทโฟนสิ้นสุดลง->ตัวอย่างที่ 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') u.indexof ('gecko')> -1 && u.indexof ('khtml') == -1, มือถือ: !! u.match (/applewebkit.*mobile.*/) || !! u.match (/applewebkit/), ios: !! u.match (// (i [^;]+; (u;)? cpu.+mac os x/), Android: u.indexof ('Android')> -1 || u.indexof ('linux') U.Indexof ('iPad')> -1, WebApp: U.Indexof ('Safari') == -1, qqbrw: u.indexof ('mqqbrowser')> -1, weixin: U.Indexof ('micromessenger')> -1, uClowend: U.IndExof ( U.Indexof ('rv: 1.2.3.4')> -1, ucweb: function () {ลอง {return parsefloat (u.match (/ucweb/d+/./d+/gi) .toString () (/d+/./d+/). tostring () {return true;} else {return false;}}} (), symbian: u.indexof ('symbian')> -1, ucsb: u.indexof ('firefox/1.')> -1};} (), liulanqi: navigator.useragent} เบราว์เซอร์ ");} else {document.write (" เบราว์เซอร์อื่น ๆ "+เบราว์เซอร์ liulanqi);} </script>