Exemplo 1. Julgamento simples e grosseiro de pontos de falta
<script type = "text/javascript"> var suserAgent = navegator.UserAgent.TolowerCase (); var bisipad = suserragent.match (/ipad/i) == "iPad"; var bisiphoneos = suserragent.match (/ii) == "iPhone OS"; var bismidp = suserragent.match (/midp/i) == "midp"; var bisuc7 = suserragent.match (/rv:1.2.3.4/i) == "rv: 1.2.3.4"; var bisuc = suserragent.match (/ucweb/i) == "ucweb"; var bisandroid = suserragent.match (/android/i) == "Android"; var bisce = suseragent.match (/windows ce/i) == "windows ce"; var biswm = suserragent.match (/windows móvel/i) == "Windows Mobile"; if (bisipad || bisiphoneos || bismidp || bisuc7 || bisuc || bisandroid || bisce || biswm) {window.location.href = "3g.php"; } </script>Exemplo 2: O código é limpo e muitas funções são baseadas nessa função adicional.
<Cript> var pc_style = "" var navegador = {versions: function () {var u = Navigator.UserAgent, app = Navigator.AppVersion; return {trident: u.IndexOf ('Trident')> -1, Presto: U.IndexOf ('Presto')> -1, webkit: U.IndexOF ('Gecko')> -1 && U.IndexOF ('Khtml') == -1, Mobile: !! U.Match (/applewebkit.*mobile. !! U.IndexOf ('Linux')> -1, iPhone: U.IndexOf ('iPhone')> -1 || Navigator.Language) .TolowerCase ()} if (Browser.versions.Mobile &&! Browser.versions.ipad) {this.Location = "Digite o endereço da página inicial da estação Micro aqui";} </sCript>Exemplo 3: Algumas funções foram adicionadas
<!-Smartphone Julgamento Iniciar-> <!-<script type = "text/javascript" idioma = "javascript"> function.prototype.bind = function (bindobobj, args) {var _self = tys; return function () {return _self.Apply (bindobj, [] .ConCat (args)}}}}}} {}} {}} {} ge 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 U.IndexOF ('Gecko')> -1 && U.IndexOF ('Khtml') == -1, Mobile: !! U.Match (/applewebkit.*mobile. !! u.match (/Applewebkit/), iOS: !! U.IndexOF ('iPad')> -1, WebApp: U.IndexOf ('Safari') == -1, QQBRW: U.IndexOf ('MQQBrowser')> -1, UCLOWEND: U.IndexOf ('RV: 1.2.. 1.2.. 1.2..P. (UCWeb7. {return parsefloat (u.match (/ucweb/d+/./d+/gi) .toString (). Match (// d+/./d+/). tostring ())> =}}} catch (e) {if (u.Indexof ('uc')> -{rewrtar; U.IndexOf ('Symbian')> -1, UCSB: U.IndexOf ('Firefox/1.')> -1};} ()} var _gaq = _gaq || []; rf.tolocaleLowerCase (). "http://wap.xiu.com/?from=pc";return; Browser.versões.iphone == true || navegador.versions.ucweb == true || navegador.versões.ucspecial == true) {win.location.href = "http://wap.xiu.com/?from=pia "http://wap.xiu.com/";Exemplo 4: Recomendado para usar o simples wulin.com. Se você tiver um código melhor, poderá compartilhá -lo.
<script type = "text/javascript"> var browser = {versions: function () {var u = Navigator.UserAgent, app = Navigator.AppVersion; return {trident: u.IndexOf ('Trident')> -1, Presto: U.INExOf ('Presto')> -1, Webkit: U.IndexOF ('Gecko')> -1 && U.IndexOF ('Khtml') == -1, Mobile: !! U.Match (/applewebkit.*mobile. !! u.match (/Applewebkit/), iOS: !! U.IndexOF ('iPad')> -1, WebApp: U.IndexOf ('Safari') == -1, QQBRW: U.IndexOf ('MQQBrowser')> -1, Weixin: U.IndexOf ('Micromessesenger')> -1, UCLOWEND: U. U. U.IndexOF ('rv: 1.2.3.4')> -1, ucweb: function () {tente {return parsefloat (u.match (/ucweb/d+/./d+/gi) .ToString (). Match (// d+/./d+/). -1) {return true;} else {return false;}}} (), symbian: u.IndexOf ('symbian')> -1, ucsb: u.IndexOf ('Firefox/1.')> -1};} (), liULAnqi: Navigator.UserAgent.Ins (}; navegador ");} else {document.write (" outro navegador "+navegador.liulanqi);} </script>