Javascript judgment smartphone Browser

Source: Internet
Author: User

Reference: http://www.cnblogs.com/phphuaibei/archive/2011/12/09/2282570.html

  

Var browser = {versions: function () {var u = navigator. userAgent, app = navigator. appVersion; return {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 iPadwebApp: u. indexOf ('safari ') =-1, // whether the web should program, no header with the bottom linux: u. indexOf ('linux ')>-1, // Add mobile with this attribute to determine the uc browser wp7: (u. indexOf ('wp7 ')>-1) | (u. indexOf ('windows Phone OS ')>-1) // trident IE kernel and contains WP7 mark Windows phone7 mobile Phone };}(), language: (navigator. browserLanguage | navigator. language ). toLowerCase ()}; document. write ("language:" + browser. language + '</br>'); document. write ("android:" + (browser. versions. mobile & browser. versions. android) + '</br>'); document. write ("iPhone:" + (browser. versions. mobile & browser. versions. iPhone) + '</br>'); document. write ("iPad:" + (browser. versions. mobile & browser. versions. iPad) + '</br>'); document. write ("Wp7:" + (browser. versions. trident & browser. versions. wp7) + '</br>'); document. write (navigator. userAgent );

 

1. Many third-party browsers, such as Baidu, QQ, and UC, are amazing. I tested the value of the UC browser on windows phone 7 for different models. The UserAgent varies greatly.

2. On the other hand, you can set the browser mode in windows phone 7 settings. There are two modes, Desktop and Mobile. These two modes have different useragents. Pay special attention to them.

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.