jQuery Method for Getting Browser Type and Version Number

  • 2021-07-01 06:38:28
  • OfStack

Needless to say, the key code is as follows:


$(document).ready(function(){
varbrow=$.browser;
varbInfo="";
if(brow.msie){bInfo="MicrosoftInternetExplorer"+brow.version;}
if(brow.mozilla){bInfo="MozillaFirefox"+brow.version;}
if(brow.safari){bInfo="AppleSafari"+brow.version;}
if(brow.opera){bInfo="Opera"+brow.version;}
alert(bInfo);
});

jQuery started with version 1.9, removing $. browser and $. browser. version and replacing them with the $. support method. For information on $. support, please refer to:

jQuery 1.9 Replaces the $. browser method with $. support

Or use the js method:


var browser = navigator.appName;
var b_version = navigator.appVersion;
var version = b_version.split(";");
var trim_Version = version[1].replace(/[ ]/g, "");
if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE9.0") {
alert("IE9");
}

Related articles: