Javascript determines how pages are accessed. computers, mobile terminals, and javascript pages
Method 1:
<Script type = "text/javascript"> function browserRedirect (type) {var sUserAgent = navigator. userAgent. toLowerCase (); var bIsIpad = sUserAgent. match (/ipad/I) = "ipad"; var bIsIphoneOs = sUserAgent. match (/iphone OS/I) = "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 = sU SerAgent. 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 = '/ctcshop/m/rhylogin.shtml'; // alert ("this is a mobile phone");} else {window. location = '/etrade/login.shtml? Ref_url =/rhy/index.html '; // alert ("this is a computer") ;}</script> // Method 1: function IsPC () {var userAgentInfo = navigator. userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v <Agents. length; v ++) {if (userAgentInfo. indexOf (Agents [v])> 0) {flag = false; break ;}} return flag ;}
Method 2:
Function browserRedirect () {var sUserAgent = navigator. userAgent. toLowerCase (); var bIsIpad = sUserAgent. match (/ipad/I) = "ipad"; var bIsIphoneOs = sUserAgent. match (/iphone OS/I) = "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 (/andro Id/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 = B page;} browserRedirect ();
Method 3:
<Script type = "text/javascript"> var browser = {versions: function () {var u = navigator. userAgent, app = navigator. appVersion; return {// mobile terminal browser version information trident: u. indexOf ('think')>-1, // IE kernel presto: u. indexOf ('presto ')>-1, // opera kernel webKit: u. indexOf ('applewebkit ')>-1, // Apple, Google kernel gecko: u. indexOf ('gecko ')>-1 & u. indexOf ('khtml ') =-1, // Firefox kernel mobile :!! U. match (/AppleWebKit. * Mobile. */) | !! U. match (/AppleWebKit/), // whether it is a mobile device ios :!! U. match (/\ (I [^;] +; (U ;)? CPU. + Mac OS X/), // ios terminal android: u. indexOf ('android')>-1 | u. indexOf ('linux ')>-1, // android terminal or uc browser iPhone: u. indexOf ('iphone ')>-1 | u. indexOf ('mac')>-1, // whether the browser is iPhone or QQHD iPad: u. indexOf ('ipad ')>-1, // whether iPad webApp: u. indexOf ('safari ') =-1, // whether the web should be a program with no header and bottom google: u. indexOf ('chrome ')>-1 };} (), language: (navigator. browserLanguage | navigator. language ). toLowerCase ()} document. writeln ("language version:" + browser. language); document. writeln ("whether it is a mobile terminal:" + browser. versions. mobile); </script>
The above is to sort out the information on how to determine the access method of the page, and continue to add relevant information in the future. Thank you for your support for this site!