JavaScript Judge page access way computer or mobile end _javascript tips

Source: Internet
Author: User

method One:

<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= 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= '/ctcsho
P/m/rhylogin.shtml ';
Alert ("This is a cell 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 (/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=b page;
 }
}
Browserredirect ();
 


Method 3:

<script type= "Text/javascript" > var browser = {Versions:function () {var u = navigator.useragent, app = Navig
 Ator.appversion;   
 return {//Mobile terminal browser version information Trident:u.indexof (' Trident ') >-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 for Mobile terminal 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 for iphone or Qqhd browser ipad:u.indexof (' ipad ') >-1,//whether IPad webapp:u.indexof (' Safari ')
 = = -1,//Whether the web should be programmed without head and bottom google:u.indexof (' Chrome ') >-1}; (), Language: (Navigator.browserlanguage | | navigator.language). toLowerCase ()} document.writeln ("language version:" +browser.la Nguage);
Document.writeln ("Whether for Mobile Terminal:" +browser.versions.mobile);

 </script>

The above is to judge the way the page Access data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.