JavaScript gets the browser type and version of the method

Source: Internet
Author: User

  This article mainly introduces JavaScript to obtain browser type and version of the method (JS get browser version), need friends can refer to the following

    Code as follows: function Getexplorerinfo () { var explorer = Window.navigator.userAgent.toLowerCase ();  // ie   if (Explorer.indexof ("MSIE") >= 0) {    var ver=explorer.match (/msie ([D.] +)/) [1];     Return {type: "IE", version:ver}; &NBSP}  //firefox   else if (Explorer.indexof ("Firefox") >= 0) {    var ver=explorer.match ( /firefox/([D.] +)/) [1];     Return {type: "Firefox", version:ver}; &NBSP}  //chrome  else if (Explorer.indexof ("Chrome") >= 0) {    var ver=explorer.match (/chrome/ ([D.] +)/) [1];      return {type: "Chrome", version:ver}; &NBSP}  //opera  else if (Explorer.indexof ("Opera") >= 0) { var ver=explorer.match (/Opera. ( [D.] +)/) [1];  return {type: "Opera", version:ver}; &NBSP}  //safari  else if (Explorer.indexof ("Safari") >= 0) { var ver=explorer.match (/version/([D.] +)/) [1];  return {type: "Safari", version:ver};  &NBSP}  alert ("Type:" +getexplorerinfo (). type+ "Nversion:" +getexplorerinfo (). version);  
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.