JS Check Browser type and version number

Source: Internet
Author: User

The lowercase information for the UserAgent property of the Navigator object is obtained first, and then the value is inferred from the regular table.

var Sys = {};var ua = Navigator.userAgent.toLowerCase (); var s;var scan; (s = Ua.match (/msie ([\d.] +)/)) ? sys.ie = S[1]: (s = Ua.match (/firefox\/([\d.] +)/)) ? Sys.firefox = S[1]: (s = Ua.match (/chrome\/([\d.] +)/)) ? Sys.chrome = S[1]: (s = Ua.match (/opera. ( [\d.] +)/)) ? Sys.opera = S[1]: (s = Ua.match (/version\/([\d.] +). *safari/))? Sys.safari = s[1]: 0;//to test if (sys.ie) {scan = "ie kernel you use" + sys.ie + "browser";} if (sys.firefox) {scan = "You are using the Firefox kernel" + sys.firefox + "browser";} if (sys.chrome) {scan = "You are using the chrome kernel" + sys.chrome + "browser";} if (sys.opera) {scan = "You are using the Opera kernel" + Sys.opera + "browser";} if (Sys.safari) {scan = "You are using the Safari kernel" + Sys.safari + "browser";} Alert (scan)


Itmyhome


JS Check Browser type and version number

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.