This article illustrates JS to determine the current page in the mobile device or in the PC end of the detailed code to share for everyone's reference, the specific content as follows
var browser = {Versions:function () {var u = navigator.useragent, app = Navigator.appve
rsion; return {//Mobile terminal browser version information Trident:u.indexof (' Trident ') >-1,//ie kernel presto:u.ind
Exof (' 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.*/),//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,//whether for IPhone or Qqhd browser Ipad:u.indexof (' ipad ') >-1,//whether the ipad webapp:u.indexof (' Safari ') = = 1//Whether the Web should be
Preface, without head and bottom}; } (), Language: (navigator.Browserlanguage | | navigator.language). toLowerCase ()} if (Browser.versions.mobile) {//Determine if the mobile device is open. Browser code under var ua = Navigator.userAgent.toLowerCase ();//Get the object to be judged if (Ua.match/micromess enger/i) = = "Micromessenger") {//Open setinterval in micro-letter (Weixinjsbridge.call (' Closewind
Ow '), 2000);
} if (Ua.match (/weibo/i) = = "WeiBo") {//On Sina Weibo client open}
if (Ua.match (/qq/i) = = "QQ") {//Open in QQ space} if (Browser.versions.ios) { Whether to open in iOS browser} if (browser.versions.android) {//
Whether to open in the Android browser} else {//otherwise is the PC Browser open window.close ();
}
Code two:JS to determine whether the user's browsing device is a mobile device or a PC
A recently made web page needs to display different page styles depending on the user's access device, mainly to determine whether a mobile device or a computer browser is accessing it.
The following gives a JS judgment processing code for reference.
<script type= "Text/javascript" > Function Browserredirect () {var Suseragen
t = 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";
Document.writeln ("Your browsing device is:"); if (Bisipad | | bisiphoneos | | bismidp | | bIsUc7 | | bisuc | | bisandroid | | bisce | | biswm) {DOCUMENT.WRITELN ("Phon
E ");
else {Document.writeln ("PC");
} browserredirect (); </script>
I use the Computer browser, Android devices, Iphone,ipad have been tested, this code is feasible, the equipment to determine the correct.
The above is the entire content of this article, I hope to help you learn.