Manish Kumar
Manish Kumar

Reputation: 507

How to get browser name using jquery or javascript?

I want to get the name of browser i am using.Currently i am trying 'navigator.userAgent' but it shows 'chrome' for both edge and chrome browser.

Upvotes: 1

Views: 6494

Answers (2)

M Sach
M Sach

Reputation: 34424

Best way is to detect is jquery-migrate with minimum and tested code which is designed to resolve any compatibility issues before using jQuery Migrate 3.0 and upgrading to jQuery 3.0.

if($.browser.mozilla) {

} 
else if($.browser.chrome) {

} 
... go on

Upvotes: 0

Manish Goswami
Manish Goswami

Reputation: 865

This is working I am too using it .It will show perfect browser name .Here is the demo

var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    // Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
    // At least Safari 3+: "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
    // Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;
    // Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
    // Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
    // Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;

Upvotes: 8

Related Questions