Exemple 1. Jugement simple et brut des points manquants
<script type = "text / javascript"> var suserager = navigator.useragent.tolowercase (); var bisipad = suseragent.match (/ iPad / i) == "iPad"; var bisiphoneos = suserager.match (/ ii) == "iPhone OS"; var bismidp = suseragent.match (/ midp / i) == "midp"; var bisuc7 = suserager.match (/rv:1.2.3.4/i) == "RV: 1.2.3.4"; var bisuc = suserager.match (/ ucweb / i) == "ucweb"; var bisandroid = suseragent.match (/ android / i) == "Android"; var bisce = suserager.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>Exemple 2: Le code est soigné et de nombreuses fonctions sont basées sur cette fonction ajoutée.
<Script> var pc_style = "" var Browser = {versions: function () {var u = Navigator.UserAgent, app = Navigator.Appversion; return {Trident: U.Indexof ('Trident')> -1, Presto: U.Indexof ('Presto')> -1, webkit: U.Indexof ('Applewebkit')> -1, gecko: 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 /), Android: U.Indexof ('android')> -1 || U.Indexof ('Linux')> -1, iPhone: U.Indexof ('iPhone')> -1 || Navigator.Language) .tolowerCase ()} if (Browser.Versions.Mobile &&! Browser.Versions.Ipad) {this.location = "Entrez l'adresse de page d'accueil de la station de micro de saut ici";} </ script>Exemple 3: certaines fonctions ont été ajoutées
<! - Démarrage du jugement du smartphone -> <! - <script type = "text / javascript" linguisétique = "javascript"> function.prototype.bind = function (bindoBj, args) {var _self = this; return function () {return _self.apply (bindoBj, [] .Concat (args))}}; function $ (id) {return "String" = Typeof id? Document.getElementById (id): id;}; var Browser = {versions: function () {var u = Navigator.UserAgent, app = Navigator.Appversion; return {Trident: U.Indexof ('Trident')> -1, Presto: U.Indexof ('Presto')> -1, WebKit: U.Indexof ('' Applewebkit ') 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 ('Mac') U.Indexof ('iPad')> -1, webApp: u.indexof ('safari') == -1, qqbrw: u.indexof ('MQQBrowser')> -1, uclowend: u.indexof ('ucweb7.')> -1, ucspecial: u.indexof (rv: 1.2.3.4 ')> -1, ucwel parsefloat (u.match (/ ucweb / d + /. / d + / gi) .toString (). Match (// d + /. / d + /). toString ())> = 8.2} catch (e) {if (u.Indexof ('uc')> -1) {return true;} else {return false;}}}} (),, symbian: symbian: symbian: U.Indexof ('Symbian')> -1, UCSB: U.Indexof ('Firefox / 1.')> -1};} ()} var _gaq = _gaq || rf.tolocalelolowercase (). indexof (". xiu.com") === -1) {var defaultJumpDomain = ""; if (defaultJumpDomain == "www") {return;} if (defaultJumpDomain == "m") {window.location.href = "http://wap.xiu.com/?from=p. == 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" </cript> -> <! - Débit du jugement du smartphone ->Exemple 4: recommandé d'utiliser le simple wulin.com. Si vous avez un meilleur code, vous pouvez le partager.
<script type = "Text / Javascript"> var Browser = {versions: function () {var u = Navigator.UserAgent, app = Navigator.Appversion; return {Trident: U.Indexof ('Trident')> -1, Presto: U.Indexof ('Presto')> -1, webkit: U.Indexof ('Applewkit') 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 ('Mac') U.Indexof ('iPad')> -1, webApp: u.indexof ('safari') == -1, qqbrw: u.indexof ('MQQBrowser')> -1, weixin: u.indexof ('Micromessenger')> -1, uclowend: u.indexof ('ucweb7.')> -1, uclowend: U.Indexof ('RV: 1.2.3.4')> -1, ucweb: function () {try {return parsefloat (u.match (/ ucweb / d + /. / d + / gi) .toString (). Match (// d + /. / d + /). toString ()> = 8.2} catch (e) {if (u.IndEx (uc ')> = 8.2) Catch (e) {if (u.IndEx (uc')> = 8) Catch (e) {if (u.IndEx (uc ')> = 8) Catch (e) {if (U.IndEx (uc')> = 8) {return true;} else {return false;}}} (), symbian: u.indexof ('symbian')> -1, ucsb: u.indexof ('firefox / 1. navigateur ");} else {document.write (" autre navigateur "+ Browser.LiulanQi);} </ Script>