javascript detect browser type

Solutions on MaxInterview for javascript detect browser type by the best coders in the world

showing results for - "javascript detect browser type"
Suzanne
10 Jun 2018
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} 
Benjamin
11 Mar 2018
1agent = {browser:{name:null,version:null,v:null,userAgent:null,app:null,os:null},mobile:false,pointlock:false};
2
3var nVer = navigator.appVersion;
4var nAgt = navigator.userAgent;
5var browserName  = navigator.appName;
6var fullVersion  = ''+parseFloat(navigator.appVersion); 
7var majorVersion = parseInt(navigator.appVersion,10);
8var nameOffset,verOffset,ix;
9agent.pointlock = 'pointerLockElement' in document ||
10    'mozPointerLockElement' in document ||
11    'webkitPointerLockElement' in document;
12
13// In Opera, the true version is after "Opera" or after "Version"
14if ((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}
63agent.browser.name = browserName;
64agent.browser.version = fullVersion;
65agent.browser.v = majorVersion;
66agent.browser.app = navigator.appName;
67agent.browser.userAgent = navigator.userAgent;
68var OSName="Unknown OS";
69if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
70if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
71if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
72if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
73
74agent.browser.os = OSName;
75agent.mobile = (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
queries leading to this page
how to check browser type in javascripthow to get javascript in browserget useragent window navigatorjs browser device detectionhow to check which browser in javascriptjava script how to detect device from the webuniquely identify a device javascriptdetect browser using jsget the default browser using javascriptknow the browser with javascriptjavascript how to check if mobivle device from google appjavascript check current devicejavascript detect browser supportnavigator browserjs detect browser typecheck os in jscheck function in browser javascriptmobile and pc and tablet html automatic detect css for allhtml indexof ie chromewindow navigator check is webhow to detect browser in javascript 2020jacvascrip 5bt find browserhow to get the browser jshow to check what is the device with jswhat is window navigatorget browser name and version in javascriptjavascript check web browserhow to detect firefox 2c chrome and internet explorer with javascriptjavascript identify browserjavascript browser detectiondevice detection js in browserhow to check what browser you are using javascriptdetect device in javascripthow to check which device we are using javascriptjs how to detect browserjs identify browserdetecting device with javascriptjavascript snippet detect platformhow to detect browser in javascriptdetect the browser in javascriptjavascript get browser namecheck what browser javascriptdetect web browser javascriptjs code to detect browserhow to identify browser in javascriptmobiledetect javascriptjavascript code to detect browseruse javascript to detect devicejavascript check device type pc tablet smartphonejavascript get mobile device informationhow to check browser compatibility using javascripthow to use find browser in htmlhow can u identify the browser in javascriptdevice details jsjavascript simple detect browerjs condition for different browsersknow browser javascriptcheck device in javascripthow to check browser in javascriptcheck the device in javascriptdetecting browser in javascriptjavascript how to detect if browser is chrome or firefoxhow to check if the mobile detect is android or ios in javascriptmobile and pc and tablet html automatic detectjs detect browsercss js detect mobile devicehow to know which browser is used using javascriptjavascript function to detect browserjavascript how to detect device typebrowser detect jsjavascript detect any browserjavascript code for broswer detectionnodejs detect osget the browser from javascripttest website on android device using chrome inspectjavascript detect osjavascript device detecthow to get the device using the site in javascripthow to detect device with jqueryjavascript detect browser codefind browser with codedetect device javascript brandhow to detect device in jsget browser and device with javascriptjavascript check if chrome or internet explorerdetect device javascriptwindow navigator useragentbrowser detection javascriptjs check browserhow to detect the device using javascriptmobile detect jsceck type of browsercheck device jsjs get browserget browser with javascriptbrowser family ie htmlhow can you detect the client 27s browser nameinternet explorer navigation in javascript identification detect browser from jsjavascript what browser detectionhtml check device typeget browser using javascriptjs check if device is mobilejs browser detection javascript browser detectwindow navigator javascriptdetect device type javascriptdevice detection for html website in javascriptjs browser detectjavascript to detect browsercheck browser javascriptonline device detection javascriptbrowser script for safari detectionjavascript check device typejavascript device detection and displaymobile detector jshow to detect browser using javascriptcheck browser using javascripthow to detect device in javascriptjavascript get type of browserrun virtualized chrome session inside a websitedetect device type in jscheck if mobile device javascriptjavascript check if its mobile in cssjavascript device detectionfind which browser using with javascriptjavascript get user broswershow to get browser type in javascriptcheck os using jshow to detect os in javascripthow to identify browsercheck the browser in javascripthow to detect a device in javascriptvalidate browser javascriptget device from browser jsphone detect jsjavascript device detectoridentify device with j avascriptcan javascript check what browser it 27s inget browser jsjavascript check browserdetect user browser javascriptcheck browser type javascripthow to get browser language using javascriptget browser javascriothow to determine browser in javascriptjavascript check if mobile devicejavascript detect client devicehow to perform js browser checkidentify the browser in javascriptget browser information javascriptget the browser user use javascriptjs check browser or applicationbrowser codes when js detectjavascript check browser typeif on mobile jsbrowser js detectionfind browser in javascriptjavascript recognize browserdevice mobile detect jsjavascript get browser typehow to detect device type in javascriptdetect device jstypescript check device type pc tablet smartphonehow to discover browser used jsidentify device javascriptuse react trigger changer in selenium java scripthow to get what browser your using javascriptis browser detection possible using javascriptdetecting device using javascriptjs check devicedetect safari javascript still detects in chromjavascript get browser name and versionjavascript how to detect browserhow to recognize device detail in jsjs if is mobileenable java in chromejavascript check if mobilejs device detectionjavascript how to check the web browserjs check device typeget browser infoget browser in javascriptjavascript check if movilemobile detect js detect browserif 28browser client 29 jsjavascript add detect browsercheck device javascripthow to check browser engine chromehow to check os in jsdetect the device or browser using jsjs detect available devicesfind bvrowser javascriptcheck current browser javascriptcheck whether browser namejs detect device typehow to find the current browser in javascriptjs tell what browserjavascript check mobile devicejavascript detect device modeltell what device jsjavascript check browser languagejs to detect devicesimple device detction in javascriptdevice detector jscheck if browser is safari or operahow to get device type in javascriptbrowser detect jsscript detect safaribrowser detection in javascriptajax determine if browser is iebrowser detection jsjavascript check if the device is mobilemobile detect jsjavascript device detection returndetect browser type javascriptcheck os javascriptdetect os using javascripthow to know the browser name in javascriptdetect mobile brand webhow to detect client browser using javascriptjavascript check if its a phonehow to detect a browser with javascript 3fnew mobiledetect 28detect os with javascriptwindow useragenthow to get browser javascriptjavascript detect device typejavascript to detect browser and devicejavascript get device typedetect javascript on browserid browser differentiate pc javascriptjs to find devicejavascript how to detect browser typedetect device htmltype of browser javascriptjavascript check if running on mobilejavascript browser checkdetect device type from javascriptjavascript check if device is phonejavascrip check browserhow to get browser in javascripthow do i detect what browser with javascriptnavigator useragent match for browser supportjs what browserget user device javascriptnavigator get os browser device javascriptbrowser name js of chromeget curency browserjavascript browser namejavascript get browserhow to determine whether website is opening in mobile or desktop using jquerybrowser type in javascriptjs test fir mobileidentify browser javascripthow to detect the browser currently being used with javascript and run a function on certain browserhow to check user browser in javascripthow to detect browser using jshow to know device with using jsjavascript check if device is mobilejavascript how to detect if browser is chrome orfirefoxlive detection in mobile phones javascripthow to detect the user browserdetect browser type on page display message suggestmobile detect min js 3fid 3dget browser url in javascripthow to detect what browser is being used with javascriptjs device datacheck javacript check browsejavascript if mobilejavascript get current browserhow to detect android device using javascripthow to check device in javascriptnavigation ie in jsjavascript how to check mobile deveicejs 2020 detect browserget devise with libray jsjavascript detect browser languagewindow navigatorhow to detect various browser in javascriptbrowser family iejavascript code to detect the browserjavascript to detect devicevar browser 3d browser 7c 7c chromedetect explorerhow to see what device javascriptget browser in jsjavascript detect devicedevice check in javascriptdevice detect js librarydevice detection by jsget browser usedget current browserhow to know which browser i am using jsdetect device info using jshow to check browser type with javascript how to detect browser using jshow to detect what device a user is on javascriptjs mobile device detectionhow to know browser in javascriptjavascript get device informationhow to identify browser in htmlhtml5 detect browserhow to check for browser in javascriptdetect browserdetect browser jasjavascript check if chrome or firefoxjavascript how to get browser informationjavascript get user browserjavscript get browserdetect browser from javascriptdetect os javascriptcheck which navigarot in use jsjavascript detect if mobile devicehow to get browser details in javascriptnavigator useragenttell js what browser is usedget browser javascriptdevice detection javascriptjavascript detect screen mobilejavascript read deviceif device not mobile jsget device in jsdetect browser javascriptdetect device jquery javascriptjavascript determine browserjavascript identify devicewindow navigationget browser info javascriptvar msie 3d ua indexof 28 22msie 22 29 3b firefoxjs get devicejavascript see what browser isget device type javascriptjavascript check if its mobiledetect if mobile device javascriptis using window navigator is best method to do ithow to check which browser is used using javascripthow to get browser information using javascriptworking of device detection javascriptdetect browser jsjava script check the browser typedetect browser type in htmldetect mobile screen in javascriptdetect device vanillaget users browser javascripthow to check browser javascripthow to detect a browser using javascriptwindow navigator useragent get current browserjavascript detect smartphonecheck browser jsjavascript browser identify deviceget device details using javascriptjs detect devicehow to check which browser is usedget browser type javascriptdetect browser and device jsjavascript if device is mobileget user browser javascriptif mobile jsdevice detect javascriptjs how to tell if in a browserrjavascript get device mobile desktopget browser details javascriptdetect which browser is being used javascriptjs detect if mobilejavascript detect browser chrome firefoxnavigator useragent detecting chrome as safarijs detect mobile browserjavascript detect browser typebrowser detect functioncheck for mobile device javascriptcheck if navigatorjs how to get current browsermobile detect js examplehow to detect browser info in javascriptdetect browser in javascriptjavascript detect browserjavascript to detect browser typedetect browser without jqueryjavascript detect browser type