1 $ (document). Ready (function () {2 / * judgment device * /3 var browser={4 versions:function () {5 var u = navigator.useragent, app = navigator.appversion;6 return {7 trident:u.indexof (' Trident ') >-1,//ie core8 presto:u.indexof (' Presto ') >-1,//opera core9 webkit:u.indexof (' AppleWebKit ') >-1,//Apple, Google kernelTen gecko:u.indexof (' Gecko ') >-1 && u.indexof (' khtml ') = = -1,//Firefox kernel One Mobile:!! U.match (/applewebkit.*mobile.*/),//Whether it is a mobile terminal A 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 the ipad:u.indexof (' ipad ') >-1,//whether ipad - webapp:u.indexof (' Safari ') = =-1,//whether the Web should be program, no head with bottom - weixin:u.indexof (' Micromessenger ') >-1,//whether (added 2015-01-22) - Qq:u.match (/\sqq/i) = = "QQ"//whether QQ + - }; + }(), A language: (navigator.browserlanguage | | navigator.language). toLowerCase () at } - if (window.orientation = = 0 | | window.orientation = = | | window.orientation = = | | window.orientation =-90 ) { - if (window.orientation = = 0 | | window.orientation = =) { - $ ("body"). attr ("Class", "Portrait"); - orientation = ' portrait '; - if (browser.versions.android| | browser.versions.iphone| | Browser.versions.iPad) {window.location.href = "mobile.html";} else{ in - } to + return false; - } the * } $ $ (window). bind (' Orientationchange ', function (e) {Panax Notoginseng if (window.orientation = = 0 | | window.orientation = = | | window.orientation = = | | window.orientation = = -90) { - if (window.orientation = = 0 | | window.orientation = =) { the $ ("body"). attr ("Class", "Portrait"); + orientation = ' portrait '; A if (browser.versions.android| | browser.versions.iphone| | Browser.versions.iPad) {window.location.href = "mobile.html";} else{ the + } - $ return false; $ } - - i} the }); - Wuyi the - Wu});
jquery Judges mobile device code snippets; PC, iphone, Android