Get browser name in JavaScript
The userAgent property inside navigator object returns the value of the user-agent header sent by the browser to the server. We can use this property to find out the browser being used.
Advertisements
console.log(navigator.userAgent); //Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
function getBrowserName() { if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1 ) { return 'Opera'; } else if(navigator.userAgent.indexOf("Chrome") != -1 ) { return 'Chrome'; } else if(navigator.userAgent.indexOf("Safari") != -1) { return 'Safari'; } else if(navigator.userAgent.indexOf("Firefox") != -1 ){ return 'Firefox'; } else if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) { return 'Internet Explorer'; } else { return 'Not sure!'; } }
getBrowserName(); //Chromw
Curly hair, very fair, please share 🙂
Related
ajax determine if browser is IE, browser name js of chrome, browser script for safari detection, browser type in javascript, browser.family ie, browser.family ie html, check browser javascript, check current browser javascript, check function in browser javascript, check what browser javascript, check whether browser name, check which navigarot in use js, Chrome and Internet Explorer with JavaScript, detect browser javascript, detect browser js, detect browser type javascript, detect browser type on page display message suggest, detect browser without jquery, detect explorer, detect the browser in javascript, enable java in chrome, get browser javascript, get browser js, get browser type javascript, get browser used, get current browser, get the default browser using javascript, get user browser javascript, get useragent window.navigator, get users browser javascript, how to check browser engine chrome, how to check browser in javascript, how to check browser javascript, how to check browser type with javascript, how to check for browser in javascript, how to detect browser in javascript, how to detect client browser using javascript, How to detect Firefox, how to discover browser used js, how to find the current browser in javascript, how to get browser javascript, how to get browser type in javascript, how to get what browser your using javascript, how to identify browser in html, how to know which browser is used using javascript, how to perform js browser check, how to use find browser in html, html indexof ie chrome, id browser differentiate pc javascript, if(browser.client) js, javascript check browser, javascript check if chrome or firefox, javascript check web browser, javascript detect browser, javascript detect browser chrome firefox, javascript detect browser type, javascript get browser, javascript get browser name, javascript get browser name and version, javascript get current browser, javascript get user broswers, javascript get user browser, javascript how to check the web browser, javascript how to detect browser type, javascript see what browser is, javascript to detect browser, javascript to detect browser type, javscript get browser, js check browser or application, js condition for different browsers, js detect browser, js how to detect browser, js how to get current browser, js identify browser, js what browser, navigation IE in js, run virtualized chrome session inside a website, script detect safari, tell js what browser is used, test website on android device using chrome inspect, use react-trigger-changer in selenium java script, var msie = ua.indexOf("MSIE "); firefox, window.navigator, window.navigator javascript, window.navigator.userAgent