navigator.useragent

//gets the type of browser
function detectBrowser() {
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 'IE';//crap
} else {
return 'Unknown';
}
}

5
1

                                    var sBrowser, sUsrAg = navigator.userAgent;

// The order matters here, and this may report false positives for unlisted browsers.

if (sUsrAg.indexOf("Firefox") > -1) {
  sBrowser = "Mozilla Firefox";
  // "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0"
} else if (sUsrAg.indexOf("SamsungBrowser") > -1) {
  sBrowser = "Samsung Internet";
  // "Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G955F Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.4 Chrome/67.0.3396.87 Mobile Safari/537.36
} else if (sUsrAg.indexOf("Opera") > -1 || sUsrAg.indexOf("OPR") > -1) {
  sBrowser = "Opera";
  // "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106"
} else if (sUsrAg.indexOf("Trident") > -1) {
  sBrowser = "Microsoft Internet Explorer";
  // "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko"
} else if (sUsrAg.indexOf("Edge") > -1) {
  sBrowser = "Microsoft Edge";
  // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
} else if (sUsrAg.indexOf("Chrome") > -1) {
  sBrowser = "Google Chrome or Chromium";
  // "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
} else if (sUsrAg.indexOf("Safari") > -1) {
  sBrowser = "Apple Safari";
  // "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1 980x1306"
} else {
  sBrowser = "unknown";
}

alert("You are using: " + sBrowser);

5 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
window.navigator.userAgent; possible navigator.userAgent js code to detect browser Navigator API: userAgent detect browser from js get the browser from javascript navigator.userAgent jquery javascript function to detect browser how to detect browser in javascript 2020 check browser js browser codes when js detect how to get browser information using javascript how to check which browser is used using javascript navigator.userAgent information browser detect js document.navigator.userAgent navigator.useragent javascript know the browser with javascript javascript identify browser detect browser jas is browser detection possible using javascript how to check browser type in javascript how to check which browser in javascript check browser type javascript get browser with javascript navigator.userAgent; windows navigator.userAgent js browser detection javascript how to detect browser how do i detect what browser with javascript detecting browser in javascript get browser information javascript navigator.useragent ios find browser in javascript how to detect browser using javascript window.navigator.useragent. how to know browser in javascript know browser javascript get browser in js javascript code to detect the browser navigator.userAgent different results in same navigator.userAgent how to get browser in javascript navigator.useragent ? detect browser using js find which browser using with javascript how to get javascript in browser Browser Detect.js (navigator.userAgent javascript code to detect browser browser detect function How to detect a browser with JavaScript? javascript browser detection check browser using javascript get browser in javascript browser detection in javascript get browser javascriot javascript what browser detection get curency browser how to check what browser you are using javascript how to know the browser name in javascript get browser and device with javascript navigator.appName how to identify browser in javascript getting user agent in javascript how to get browser language using javascript javascript to detect browser and device detect javascript on browser javascript detect browser support detect safari javascript still detects in chrom window.navigator.useragent get current browser javascript recognize browser javascript browser name javascript code for broswer detection get browser info get browser url in javascript check the browser in javascript check javacript check browse how to detect various browser in javascript javascript console log user agent js get useragent js detect mobile browser html page show user agent find browser with code js get current user agent detect browser javascript get browser type get the browser user use javascript user agent in js find user agent in javascript how to detect the browser currently being used with javascript and run a function on certain browser browser js detection How to detect the user browser js tell what browser how to check which browser is used how to detect browser using JS how to detect browser using JS javascript simple detect brower javascript how to detect if browser is chrome or firefox javascript how to detect if browser is chrome orfirefox get user agent js javascrip check browser javascript determine browser javascript check browser language js 2020 detect browser check if browser is safari or opera window navigation how can you detect the client's browser name how to detect browser info in javascript how to know which browser i am using js js navigator.useragent browser detection javascript get browser using javascript get browser info javascript navigator.useaggent() navigator.userAgent explained navigator.userAgent how to use navigator.userAgent how to usr navigator.userAgent what is identify browser javascript find bvrowser javascript jacvascrip[t find browser window.navigator.platform plugin how to identify browser javascript navigator.useragent detect web browser javascript detect browser in javascript ceck type of browser html5 detect browser console.log(navigator.userAgent) javascript check browser type check if navigator js user agent window navigator check is web how to check user browser in javascript what is an agent javascript javascript detect browser language js check browser get browser name and version in javascript js get browser javascript http_user_agent internet explorer navigation in javascript identification user agent js window.useragent javascript check if chrome or internet explorer type of browser javascript is using window navigator is best method to do it javascript snippet detect platform javascript detect any browser user agent string javascript js browser detect javascript browser detect javascript browser check navigator useragent match for browser support navigator browser user agent in javas js how to tell if in a browserr javascript get type of browser javascript user agent. javascript useragent. navigator get user agent javascript navigator get os browser device javascript get user agent javascript navigator useragent js get agent information view useragent javascript javascript get my user agent navigator.uerAgent js navigator.useragentheader detect browser type in html javascript detect browser code get useragent javascript what is window.navigator navigator.userAgent on the server validate browser javascript navigator.useragent javascript get user agent how to get user agent in javascript js get user agent javascript user agent javascript user_agent useragent javascript display useragent javascript javascript browser navigation user agent navigator user agent navigator.useragentData navigator.useragent data navigator.useragent detecting chrome as safari var browser = browser || chrome display user agent-defined property how to check browser compatibility using javascript script detect safari javascript see what browser is get the default browser using javascript window.navigator check current browser javascript window.navigator javascript get users browser javascript id browser differentiate pc javascript javscript get browser javascript get browser name and version check which navigarot in use js html indexof ie chrome get useragent window.navigator detect browser type on page display message suggest window.navigator.userAgent get browser type javascript detect browser type javascript js condition for different browsers how to check browser in javascript javascript get user browser get current browser javascript get current browser check function in browser javascript navigation IE in js how to know which browser is used using javascript how to find the current browser in javascript browser type in javascript get user browser javascript how to get browser type in javascript javascript get user broswers javascript to detect browser type how to check browser engine chrome tell js what browser is used js check browser or application get browser used detect explorer check whether browser name get browser js javascript how to detect browser type how to discover browser used js how to check for browser in javascript browser.family ie html browser.family ie javascript check web browser javascript detect browser chrome firefox how to perform js browser check javascript how to check the web browser if(browser.client) js detect browser js js what browser how to detect browser in javascript detect the browser in javascript how to identify browser in html js how to detect browser how to get what browser your using javascript check what browser javascript detect browser without jquery javascript get browser name js detect browser how to detect client browser using javascript enable java in chrome run virtualized chrome session inside a website use react-trigger-changer in selenium java script test website on android device using chrome inspect get browser javascript how to check browser type with javascript ajax determine if browser is IE browser script for safari detection check browser javascript javascript detect browser type javascript to detect browser How to detect Firefox, Chrome and Internet Explorer with JavaScript javascript check if chrome or firefox browser name js of chrome var msie = ua.indexOf("MSIE "); firefox how to use find browser in html how to check browser javascript js identify browser js how to get current browser detect browser javascript javascript detect browser how to get browser javascript javascript check browser javascript get browser detect user browser javascript
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source