javascript get browser name

Solutions on MaxInterview for javascript get browser name by the best coders in the world

showing results for - "javascript get browser name"
Pietro
06 Nov 2020
1//gets the type of browser
2function detectBrowser() { 
3    if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1 ) {
4        return 'Opera';
5    } else if(navigator.userAgent.indexOf("Chrome") != -1 ) {
6        return 'Chrome';
7    } else if(navigator.userAgent.indexOf("Safari") != -1) {
8        return 'Safari';
9    } else if(navigator.userAgent.indexOf("Firefox") != -1 ){
10        return 'Firefox';
11    } else if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) {
12        return 'IE';//crap
13    } else {
14        return 'Unknown';
15    }
16} 
Miranda
25 Sep 2020
1var nVer = navigator.appVersion;
2var nAgt = navigator.userAgent;
3var browserName  = navigator.appName;
4var fullVersion  = ''+parseFloat(navigator.appVersion); 
5var majorVersion = parseInt(navigator.appVersion,10);
6var nameOffset,verOffset,ix;
7
8// In Opera 15+, the true version is after "OPR/" 
9if ((verOffset=nAgt.indexOf("OPR/"))!=-1) {
10 browserName = "Opera";
11 fullVersion = nAgt.substring(verOffset+4);
12}
13// In older Opera, the true version is after "Opera" or after "Version"
14else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
15 browserName = "Opera";
16 fullVersion = nAgt.substring(verOffset+6);
17 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
18   fullVersion = nAgt.substring(verOffset+8);
19}
20// In MSIE, the true version is after "MSIE" in userAgent
21else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
22 browserName = "Microsoft Internet Explorer";
23 fullVersion = nAgt.substring(verOffset+5);
24}
25// In Chrome, the true version is after "Chrome" 
26else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
27 browserName = "Chrome";
28 fullVersion = nAgt.substring(verOffset+7);
29}
30// In Safari, the true version is after "Safari" or after "Version" 
31else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
32 browserName = "Safari";
33 fullVersion = nAgt.substring(verOffset+7);
34 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
35   fullVersion = nAgt.substring(verOffset+8);
36}
37// In Firefox, the true version is after "Firefox" 
38else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
39 browserName = "Firefox";
40 fullVersion = nAgt.substring(verOffset+8);
41}
42// In most other browsers, "name/version" is at the end of userAgent 
43else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < 
44          (verOffset=nAgt.lastIndexOf('/')) ) 
45{
46 browserName = nAgt.substring(nameOffset,verOffset);
47 fullVersion = nAgt.substring(verOffset+1);
48 if (browserName.toLowerCase()==browserName.toUpperCase()) {
49  browserName = navigator.appName;
50 }
51}
52// trim the fullVersion string at semicolon/space if present
53if ((ix=fullVersion.indexOf(";"))!=-1)
54   fullVersion=fullVersion.substring(0,ix);
55if ((ix=fullVersion.indexOf(" "))!=-1)
56   fullVersion=fullVersion.substring(0,ix);
57
58majorVersion = parseInt(''+fullVersion,10);
59if (isNaN(majorVersion)) {
60 fullVersion  = ''+parseFloat(navigator.appVersion); 
61 majorVersion = parseInt(navigator.appVersion,10);
62}
63
64document.write(''
65 +'Browser name  = '+browserName+'<br>'
66 +'Full version  = '+fullVersion+'<br>'
67 +'Major version = '+majorVersion+'<br>'
68 +'navigator.appName = '+navigator.appName+'<br>'
69 +'navigator.userAgent = '+navigator.userAgent+'<br>'
70)
71
queries leading to this page
get curency browserget browser information javascriptbrowser codes when js detecthow to check browser name in javascripthow to detect browser using javascriptjavascrip check browserif 28browser client 29 jshow to identify browser in htmljs how to detect browserjavascript get browserfind name of current website javascriptbrowser family ie htmldetect safari javascript still detects in chromget browser details javascriptget the browser name in javascriptget browser in javascriptjavascript detect browser supporthow to check what browser you are using javascriptjs detect browserjavascript browser detectdetect user browser javascriptbrowser family iehow to detect client browser using javascriptknow the browser with javascripthow to detect firefox 2c chrome and internet explorer with javascriptwindow navigator useragentjs condition for different browsersjavascript code to detect the browserhow to find browser name in javascriptjavascript code for broswer detectionbrowser js detectioncheck if navigatorfind bvrowser javascriptfind browser in javascriptget browser type javascriptfind which browser using with javascriptis browser detection possible using javascriptjavascript determine browserinternet explorer navigation in javascript identification javascript browser checkjs how to tell if in a browserrjs get browserhow to get browser information using javascriptdetect browser type on page display message suggest how to detect browser using jsjs browser detecthow to check browser type in javascripthow to discover browser used jsdetect web browser javascriptwindow navigationcheck browser javascriptjs tell what browserdetect browser javascriptjavascript check browserhow to detect what browser is being used with javascripthow to identify browser in javascriptdetect javascript on browserhow to use find browser in htmljavascript detect browser languagejavascript retrieve browser namejs code to detect browserhow to check which browser is usedhow to detect browser name in javascripttell js what browser is usedjavascript get browser namedetect browser jasdetect explorerget browser name and version in javascriptbrowser detection jswith javascript how can you find browser namejava script check the browser typehow to detect browser in javascript 2020navigation ie in jsjavascript detect browser chrome firefoxhow to get the browser jsget browser javascriotjs browser detection get browser name from javascripthow to know which browser i am using jscheck function in browser javascripthow to know browser name in javascriptidentify browser javascriptjs what browserjavascript detect any browserhow to check user browser in javascriptjs check browser or applicationjavascript snippet detect platformhow to get browser details in javascripthow to detect a browser using javascriptwindow navigator useragent get current browserdetect browser event javascript 5bhow to detect various browser in javascriptnavigator browserget browser name javascriptjs identify browserhow to get browser in javascriptjavascript to detect browserget browser nameget browser info javascriptcheck browser name jsceck type of browserjavascript get user broswerswindow navigator javascripthow to get what browser your using javascripthow to know which browser is used using javascriptcheck whether browser namefind browser with codejs check browserjavascript get browser name and versionidentify the browser in javascriptjavascript add detect browserdetect browser from jsjavascript get browser typeget the browser from javascriptknow browser javascriptjavascript identify browserhow to find the current browser in javascriptjs 2020 detect browserjacvascrip 5bt find browserdetect browser jsget browser with javascriptget name of browser javascriptwindow navigatordetect browser and device jshow to know the browser name in javascriptdetect browser name javascriptdetect browserhow to get browser javascriptjs detect mobile browserjavascript browser detectiondetecting browser in javascriptjs detect browser typehow to check browser javascriptjavascript how to check the web browserjs find browser namedetect browser without jqueryget browser in jsjavascript browser namejavascript detect browser codejavascript what browser detectionscript detect safariget browser using javascriptbrowser detect jshow to check browser compatibility using javascriptjs how to get current browserjavascript see what browser iswhat is window navigatorjavascript how to detect browserbrowser detect jsjavascript user agent to browser namedetect browser type in htmlhow to get browser language using javascripthow to find the browser name in javascriptbrowser type in javascriptcheck which navigarot in use jswindow navigator check is webhow to get javascript in browserjavascript detect browser namehow to detect the browser currently being used with javascript and run a function on certain browsernavigator useragent match for browser supportget user browser javascripthow to check browser engine chromejavascript to detect browser and devicehow to get browser name jsget browser name in jsjavascript simple detect browerjavascript check if chrome or internet explorerdetect browser in javascripthow do i detect what browser with javascriptenable java in chromedetect browser name jshow to know browser in javascriptdetect browser from javascriptget browser name using jsuse react trigger changer in selenium java scriptvar browser 3d browser 7c 7c chromehow to check which browser is used using javascriptfind browser name in javascriptjs get browser namebrowser detect functionhow to get browser name using javascripttest website on android device using chrome inspectcheck browser name in javascriptget browser name in javascriptget browser and device with javascripthow to determine browser in javascriptjavascript check web browserhow to detect browser using jsis using window navigator is best method to do itjavascript to detect browser typehow to detect the user browserhow to check for browser in javascripthow to check which browser in javascriptjavascript recognize browsernavigator useragentdetect the browser in javascriptget users browser javascripttype of browser javascripthow to check browser type with javascriptjavascript how to detect if browser is chrome orfirefoxjavascript check browser languagehow to detect a browser with javascript 3fjavascript get user browserjavascript get page namecheck javacript check browsedetect browser with javascripthow to get the browser name in javascriptjavascript detect browser typejavascript how to detect if browser is chrome or firefoxdisplay current browser name in javascriptvar msie 3d ua indexof 28 22msie 22 29 3b firefoxhow to get current browser name in javascriptcheck if browser is safari or operawindow useragentnavigator useragent detecting chrome as safarihtml indexof ie chromejavascript get type of browserhow to check browser in javascriptrun virtualized chrome session inside a websitejavascript how to get browser informationcheck browser jsjavascript get name of browsernavigator get os browser device javascriptbrowser detection javascriptget useragent window navigatorbrowser detection in javascriptcheck current browser javascriptjavascript how to detect browser typeget browser javascipthow to detect browser info in javascripthow can u identify the browser in javascriptcheck browser type javascriptid browser differentiate pc javascripthow to perform js browser checkhow to get browser name in javascriptget the default browser using javascriptget browser usedcheck the browser in javascriptajax determine if browser is iejavascript function to detect browserhow can you detect the client 27s browser namehow to get name of browser javascriptget browser url in javascriptget browser infovalidate browser javascriptjavscript get browserget current browserget the browser user use javascriptjavascript get current browserget browser javascripthow to identify browserhow to detect browser in javascriptcan javascript check what browser it 27s indetect browser type javascriptjavascript detect browserget browser jsjs know browser namejavascript check browser typedetect which browser is being used javascriptdetect browser using jsjavascript code to detect browserhow to get browser type in javascriptbrowser script for safari detectionbrowser name js of chromehtml5 detect browserjavascript check if chrome or firefoxcheck browser using javascriptcheck what browser javascriptjavascript get browser name