165

I have tried using the code below but it only display results in Chrome and Mozilla not working in IE6.

<div id="example"></div>

<script type="text/javascript">

txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";

document.getElementById("example").innerHTML=txt;

</script>

Output:

Browser CodeName: Mozilla

Browser Name: Netscape

Browser Version: 5.0 (Windows)

Cookies Enabled: true

Platform: Win32

User-agent header: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0

I need to get the version "Firefox/12.0" only.

Himanshu
  • 31,810
  • 31
  • 111
  • 133
capri
  • 2,047
  • 5
  • 19
  • 11

13 Answers13

217

Detecting browser's details:

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var fullVersion  = ''+parseFloat(navigator.appVersion); 
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;

// In Opera, the true version is after "OPR" or after "Version"
if ((verOffset=nAgt.indexOf("OPR"))!=-1) {
 browserName = "Opera";
 fullVersion = nAgt.substring(verOffset+4);
 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
   fullVersion = nAgt.substring(verOffset+8);
}
// In MS Edge, the true version is after "Edg" in userAgent
else if ((verOffset=nAgt.indexOf("Edg"))!=-1) {
 browserName = "Microsoft Edge";
 fullVersion = nAgt.substring(verOffset+4);
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "Microsoft Internet Explorer";
 fullVersion = nAgt.substring(verOffset+5);
}
// In Chrome, the true version is after "Chrome" 
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
 browserName = "Chrome";
 fullVersion = nAgt.substring(verOffset+7);
}
// In Safari, the true version is after "Safari" or after "Version" 
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
 browserName = "Safari";
 fullVersion = nAgt.substring(verOffset+7);
 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
   fullVersion = nAgt.substring(verOffset+8);
}
// In Firefox, the true version is after "Firefox" 
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
 browserName = "Firefox";
 fullVersion = nAgt.substring(verOffset+8);
}
// In most other browsers, "name/version" is at the end of userAgent 
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < 
          (verOffset=nAgt.lastIndexOf('/')) ) 
{
 browserName = nAgt.substring(nameOffset,verOffset);
 fullVersion = nAgt.substring(verOffset+1);
 if (browserName.toLowerCase()==browserName.toUpperCase()) {
  browserName = navigator.appName;
 }
}
// trim the fullVersion string at semicolon/space if present
if ((ix=fullVersion.indexOf(";"))!=-1)
   fullVersion=fullVersion.substring(0,ix);
if ((ix=fullVersion.indexOf(" "))!=-1)
   fullVersion=fullVersion.substring(0,ix);

majorVersion = parseInt(''+fullVersion,10);
if (isNaN(majorVersion)) {
 fullVersion  = ''+parseFloat(navigator.appVersion); 
 majorVersion = parseInt(navigator.appVersion,10);
}

document.write(''
 +'Browser name  = '+browserName+'<br>'
 +'Full version  = '+fullVersion+'<br>'
 +'Major version = '+majorVersion+'<br>'
 +'navigator.appName = '+navigator.appName+'<br>'
 +'navigator.userAgent = '+navigator.userAgent+'<br>'
)

Source JavaScript: browser name.
See JSFiddle to detect Browser Details.

Detecting OS:

// This script sets OSName variable as follows:
// "Windows"    for all versions of Windows
// "MacOS"      for all versions of Macintosh OS
// "Linux"      for all versions of Linux
// "UNIX"       for all other UNIX flavors 
// "Unknown OS" indicates failure to detect the OS

var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

document.write('Your OS: '+OSName);

Source JavaScript: OS detection.
See JSFiddle to detect OS Details.

Himanshu
  • 31,810
  • 31
  • 111
  • 133
  • 1
    Do you know where I could find all the possible values of appVersion? Well all the possible OS values that appVersion uses? – John Odom Aug 01 '14 at 15:12
  • 4
    @JohnOdom New systems, (e.g. the upcoming Steam box) probably have their own names; and existing systems might change their names or shorthands. You will never be up-to-date, unless you use some sort of global database to get that information from; since this is entirely proprietary. Maybe some day, Google, W3 etc. will offer an API to crowdsource and make publicly available all the different system names and their relations that they gather from their users. – Domi Mar 15 '15 at 06:20
  • 1
    verOffset=nAgt.indexOf("Opera"))!=-1. This won't work for Opera 20 and above. – parth.hirpara Sep 17 '15 at 07:17
  • For opera you can use this condition ---> (verOffset=nAgt.indexOf("Opera"))!=-1 || (nVendor != undefined && (nVendor.indexOf("Opera"))!=-1 && (verOffset=nAgt.indexOf("OPR"))!=-1) – parth.hirpara Sep 17 '15 at 07:24
  • This code from 2012 it not up to date anymore. It would be very nice if you could update it. Opera does not report "Opera" anymore. It uses "OPR" now instead. And since Internet Explorer 11 the string "MSIE" is not present anymore. Additionally the detection of Edge is missing. – Elmue Dec 04 '15 at 17:35
  • Shouldn't the platform "X11" be returned as "Linux" instead ? – Elmue Dec 04 '15 at 21:31
  • for detecting OS is more suitable `navigator.platform` object – Dee Dec 30 '15 at 09:41
  • This OS detection cause trouble in Android Studio download page because Firefox (Fedora Linux) merely return "5.0 (X11)" when query `navigator.appVersion`, no such "Linux" term, and they didn't check for X11 at all because no support to UNIX. – 林果皞 Jul 31 '16 at 09:58
  • 2
    Unable to detect Edge. – Mohan Singh Feb 04 '19 at 13:42
  • 4
    This Javascript is out of date. Reports Edge and IE 11 as "Netscape 5". Suggest using a maintained library for this functionality like https://github.com/faisalman/ua-parser-js – James Boutcher Mar 12 '19 at 15:48
  • There must be something better than ua-parser-js which is tons of unformatted, difficult to understand code crammed into one line which has previously been severely compromised and exploited. – Trashman Oct 17 '22 at 06:36
  • Your code is detecting Opera and Edge as Chrome.. – Beamer Jan 04 '23 at 20:08
  • @MohanSingh I updated to properly detect Edge and also updated code for Opera. – Himanshu Jan 05 '23 at 06:04
  • 1
    @JamesBoutcher I updated to properly detect Edge and also updated code for Opera. – Himanshu Jan 05 '23 at 06:04
  • 1
    @Beamer I updated to properly detect Edge and also updated code for Opera. – Himanshu Jan 05 '23 at 06:04
  • @Trashman were you perhaps looking at the minified version? Please compare to the [full source here](https://github.com/faisalman/ua-parser-js/blob/master/src/ua-parser.js). And are you saying that specifically ua-parser-js has been severely compromised and exploited? Or did you mean that about _all the minified code which is used in the entire world_? If the latter, please share news sources for that? – Walter Monroe Jan 20 '23 at 11:39
  • 1
    @WalterMonroe I was referring specifically to ua-parser-js specifically being compromised multiple times in the past. Here is my source: https://www.cisa.gov/uscert/ncas/current-activity/2021/10/22/malware-discovered-popular-npm-package-ua-parser-js – Trashman Jan 23 '23 at 15:00
  • @Trashman thanks for the info. I followed the links all the way to the repo owner's response. If it's true that his npm account was hijacked, then the issue was with npm, not with ua-parser-js. It could've happened to any npm account. It was resolved quickly and responsibly with no more incidences since Oct 22, 2021. It's still great code. https://github.com/faisalman/ua-parser-js/issues/536#issuecomment-949742904 – Walter Monroe Jan 23 '23 at 19:41
  • iPadOS 16.3 is detected as MacOs – nicopowa Mar 01 '23 at 23:35
30

Update

I had some good experiences with Platform.js (demo here), but still, caution is adviced:

Original Post

I'd like to refer you to the author of WhichBrowser: Everybody lies.

Basically, no browser is being honest. No matter if you use Chrome or IE, they both will tell you that they are "Mozilla Netscape" with Gecko and Safari support. Try it yourself on any of the fiddles flying around in this thread:

hims056's fiddle

Hariharan's fiddle

or any other... Try it with Chrome (which might still succeed), then try it with a recent version of IE, and you will cry. Of course, there are heuristics, to get it all right, but it will be tedious to grasp all the edge cases, and they will very likely not work anymore in a year's time.

Take your code, for example:

<div id="example"></div>
<script type="text/javascript">
txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";
document.getElementById("example").innerHTML=txt;
</script>

Chrome says:

Browser CodeName: Mozilla

Browser Name: Netscape

Browser Version: 5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36

Cookies Enabled: true

Platform: Win32

User-agent header: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36

IE says:

Browser CodeName: Mozilla

Browser Name: Netscape

Browser Version: 5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; rv:11.0) like Gecko

Cookies Enabled: true

Platform: Win32

User-agent header: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; rv:11.0) like Gecko

At least Chrome still has a string that contains "Chrome" with the exact version number. But, for IE you must extrapolate from the things it supports to actually figure it out (who else would boast that they support .NET or Media Center :P), and then match it against the rv: at the very end to get the version number. Of course, even such sophisticated heuristics might very likely fail as soon as IE 12 (or whatever they want to call it) comes out.

Domi
  • 22,151
  • 15
  • 92
  • 122
  • 3
    Its displaying Chrome for Opera browser. – Raj Aug 26 '15 at 14:36
  • 1
    some of those properties are "kept for backward compatibility", e.g. all browsers will return "Netscape" for `navigator.appName` → https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID – Philipp May 23 '20 at 15:57
27

To detect operating system using JavaScript it is better to use navigator.userAgent instead of navigator.appVersion

{
  var OSName = "Unknown OS";
  if (navigator.userAgent.indexOf("Win") != -1) OSName = "Windows";
  if (navigator.userAgent.indexOf("Mac") != -1) OSName = "Macintosh";
  if (navigator.userAgent.indexOf("Linux") != -1) OSName = "Linux";
  if (navigator.userAgent.indexOf("Android") != -1) OSName = "Android";
  if (navigator.userAgent.indexOf("like Mac") != -1) OSName = "iOS";
  console.log('Your OS: ' + OSName);
}
Nisal Edu
  • 7,237
  • 4
  • 28
  • 34
24

There is a library for this purpose: https://github.com/bestiejs/platform.js#readme

Then you can use it this way

// example 1
platform.os; // 'Windows Server 2008 R2 / 7 x64'

// example 2 on an iPad
platform.os; // 'iOS 5.0'

// you can also access on the browser and some other properties
platform.name; // 'Safari'
platform.version; // '5.1'
platform.product; // 'iPad'
platform.manufacturer; // 'Apple'
platform.layout; // 'WebKit'

// or use the description to put all together
platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'
timaschew
  • 16,254
  • 6
  • 61
  • 78
  • 1
    Note that from all al the links to github-libraries in the answers here, this library seems to be the most up-to-date (Writing in May 2018, with the last commit '3 months ago') – Ideogram May 12 '18 at 05:44
  • This library still has great support. Used it recently and works correctly. – Jorge Peña Oct 12 '22 at 19:46
9

PPK's script is THE authority for this kind of things, as @Jalpesh said, this might point you in the right way

var wn = window.navigator,
        platform = wn.platform.toString().toLowerCase(),
        userAgent = wn.userAgent.toLowerCase(),
        storedName;

// ie
    if (userAgent.indexOf('msie',0) !== -1) {
        browserName = 'ie';
        os = 'win';
        storedName = userAgent.match(/msie[ ]\d{1}/).toString();
        version = storedName.replace(/msie[ ]/,'');

        browserOsVersion = browserName + version;
    }

Taken from https://github.com/leopic/jquery.detectBrowser.js/blob/sans-jquery/jquery.detectBrowser.sansjQuery.js

leopic
  • 2,958
  • 2
  • 27
  • 42
3

Try this one..

// Browser with version  Detection
navigator.sayswho= (function(){
    var N= navigator.appName, ua= navigator.userAgent, tem;
    var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
    if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
    M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
    return M;
})();

var browser_version          = navigator.sayswho;
alert("Welcome to " + browser_version);

check out the working fiddle ( here )

Hariharan G R
  • 539
  • 2
  • 9
2

For Firefox, Chrome, Opera, Internet Explorer and Safari

var ua="Mozilla/1.22 (compatible; MSIE 10.0; Windows 3.1)";
//ua = navigator.userAgent;
var b;
var browser;
if(ua.indexOf("Opera")!=-1) {

    b=browser="Opera";
}
if(ua.indexOf("Firefox")!=-1 && ua.indexOf("Opera")==-1) {
    b=browser="Firefox";
    // Opera may also contains Firefox
}
if(ua.indexOf("Chrome")!=-1) {
    b=browser="Chrome";
}
if(ua.indexOf("Safari")!=-1 && ua.indexOf("Chrome")==-1) {
    b=browser="Safari";
    // Chrome always contains Safari
}

if(ua.indexOf("MSIE")!=-1 && (ua.indexOf("Opera")==-1 && ua.indexOf("Trident")==-1)) {
    b="MSIE";
    browser="Internet Explorer";
    //user agent with MSIE and Opera or MSIE and Trident may exist.
}

if(ua.indexOf("Trident")!=-1) {
    b="Trident";
    browser="Internet Explorer";
}

// now for version


var version=ua.match(b+"[ /]+[0-9]+(.[0-9]+)*")[0];

console.log("broswer",browser);
console.log("version",version);
vusan
  • 5,221
  • 4
  • 46
  • 81
2

I wasn't able to get some of the other answers to work on Chrome, Firefox, IE11, and Edge with the same code. I came up with the below and it appears to work for those browsers listed above. I also wanted to see what OS the user was on. I haven't tested this against a browser with user overridden User-Agent settings, so mileage may vary. The order of the IFs is important for this to work correctly.

let os, osStore, bStore, appVersion, browser;
// Chrome
if(navigator.vendor === "Google Inc."){
    appVersion = navigator.appVersion.split(" ");
    os = [appVersion[1],appVersion[2],appVersion[3],appVersion[4],appVersion[5]].join(" ");
    os = os.split("(")[1].split(")")[0]
    browser = appVersion[appVersion.length-2].split("/").join(" ");
    console.log("Browser:",browser,"- OS:",os);
}

// Safari
else if(navigator.vendor === "Apple Computer, Inc."){
    appVersion = navigator.appVersion.split(" ");
    os = [appVersion[1],appVersion[2],appVersion[3],appVersion[4],appVersion[5]].join(" ");
    os = os.split("(")[1].split(")")[0];
    browser = appVersion[appVersion.length-1].split("/").join(" ");
    console.log("Browser:",browser,"- OS:",os);
}

// Firefox is seems the only browser with oscpu
else if(navigator.oscpu){
    bStore = navigator.userAgent.split("; ").join("-").split(" ");
    browser = bStore[bStore.length-1].replace("/"," ");
    osStore = [bStore[1],bStore[2],bStore[3]].join(" ");
    osStore = osStore.split("-");
    osStore.pop(osStore.lastIndexOf)
    osStore = osStore.join(" ").split("(");
    os = osStore[1];
    console.log("Browser:",browser,"- OS:",os);
}

// IE is seems the only browser with cpuClass
// MSIE 11:10 Mode
else if(navigator.appName === "Microsoft Internet Explorer"){
    bStore = navigator.appVersion.split("; ");
    browser = bStore[1]+" / "+bStore[4].replace("/"," ");
    os = [bStore[2],bStore[3]].join(" ");
    console.log("Browser:",browser,"- OS:",os);
}

// MSIE 11
else if(navigator.cpuClass){
    bStore = navigator.appVersion.split("; ");
    osStore = [bStore[0],bStore[1]].join(" ");
    os = osStore.split("(")[1];
    browser = "MSIE 11 "+bStore[2].split("/").join(" ");
    console.log("Browser:",browser,"- OS:",os);
}

// Edge
else if(navigator.appVersion){
    browser = navigator.appVersion.split(" ");
    browser = browser[browser.length -1].split("/").join(" ");
    os = navigator.appVersion.split(")")[0].split("(")[1];
    console.log("Browser:",browser,"- OS:",os);
}

// Other browser
else {
    console.log(JSON.stringify(navigator));
}
Dan Awesome
  • 91
  • 1
  • 2
  • 9
2

There are 3 libraries for this purpose. You can compare them online https://www.whatsmyua.info (load this page in different browsers & devices) and choose the best one that fits your needs.

  1. usage example for platform.js
<script src="platform.js"></script>
// on an iPad
platform.name; // 'Safari'
platform.version; // '5.1'
platform.product; // 'iPad'
platform.manufacturer; // 'Apple'
platform.layout; // 'WebKit'
platform.os; // 'iOS 5.0'
platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'

// or parsing a given UA string
var info = platform.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 11.52');
info.name; // 'Opera'
info.version; // '11.52'
info.layout; // 'Presto'
info.os; // 'Mac OS X 10.7.2'
info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'
  1. usage example for ua-parser.js
<script src="ua-parser.min.js"></script>
var parser = new UAParser();
console.log(parser.getResult());
/*
    /// This will print an object structured like this:
    {
        ua: "",
        browser: {
            name: "",
            version: "",
            major: "" //@deprecated
        },
        engine: {
            name: "",
            version: ""
        },
        os: {
            name: "",
            version: ""
        },
        device: {
            model: "",
            type: "",
            vendor: ""
        },
        cpu: {
            architecture: ""
        }
    }
*/
// Default result depends on current window.navigator.userAgent value

// Now let's try a custom user-agent string as an example
var uastring1 = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2";
parser.setUA(uastring1);
var result = parser.getResult();
// You can also use UAParser constructor directly without having to create an instance:
// var result = UAParser(uastring1);

console.log(result.browser);        // {name: "Chromium", version: "15.0.874.106"}
console.log(result.device);         // {model: undefined, type: undefined, vendor: undefined}
console.log(result.os);             // {name: "Ubuntu", version: "11.10"}
console.log(result.os.version);     // "11.10"
console.log(result.engine.name);    // "WebKit"
console.log(result.cpu.architecture);   // "amd64"
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
2

2023:

navigator.platform and navigator.appVersion are deprecated, and navigator.userAgent is being reduced to contain less info, which has gradually happened between chrome version 100-113.

The modern way is to use navigator.userAgentData, it's very nice and declaritive: enter image description here

See more details in this google blog.

However, please note that FireFox and Safari hasn't adopted it yet, so this answer is a future-oriented one. Be sure to check caniuse before use.

ZYinMD
  • 3,602
  • 1
  • 23
  • 32
1

I needed a 2023 code to handle iPhone and iPad separately.

navigator.platform is deprecated.

I just typed a savage code for a late night experiment.

Tested with iPhone & iPad 16.3, Android Phone, Windows 10.

Missing Android Tablets.

Not tested on Mac & Linux.

navigator.maxTouchPoints is tested greater or equal to work with Chrome simulator, remove equal to test with real devices.

About browser name and version, it's a bit tricky these days, navigator.appVersion is also deprecated.

There are many x.xx.xxx matches in userAgent, maybe the one we want is always the last.

Or not, my Samsung S10 userAgent is :

Mozilla/5.0 (Linux; Android 12; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Mobile Safari/537.36

Is it a Linux system running some Mozilla code using Safari to sandbox Chrome and make it run on an Android device ? omg

So I removed the leading "Mozilla/x.x, introduced an offset and ignored iOs version.

Don't use in production.

Anyway, the code should not rely on what machine it's running on.

Had a lot of fun though.

(() => {

console.log(navigator.userAgent);

let ua = navigator.userAgent.toLowerCase().replace(/^mozilla\/\d\.\d\W/, "");

let mobiles = {
            
        "iphone": /iphone/, 
        "ipad": /ipad|macintosh/, 
        "android": /android/
        
    };
    desktops = {

        "windows": /win/, 
        "mac": /macintosh/, 
        "linux": /linux/

    };

let os = Object.keys(mobiles)
.find(os => mobiles[os].test(ua) && navigator.maxTouchPoints >= 1) 
|| 
Object.keys(desktops)
.find(os => desktops[os].test(ua));

let browserTest = ua.match(/(\w+)\/(\d+\.\d+(?:\.\d+)?(?:\.\d+)?)/g), 
    browserOffset = browserTest.length && (browserTest.length > 2 && !(/^(ver|cri|gec)/.test(browserTest[1])) ? 1 : 0), 
    browserResult = browserTest.length && browserTest[browserTest.length - 1 - browserOffset].split("/"), 
    browser = browserResult && browserResult[0], 
    version = browserResult && browserResult[1];

console.log(os, browser, version);

})();

Fun facts :

  • iPhone 12 mini iOs 16.3 userAgent returns iOs 16.1
  • Firefox on Android is detected
  • All browsers on iOs return Safari
  • It's a complete mess
nicopowa
  • 459
  • 3
  • 11
0

Code to detect the operating system of an user

let os = navigator.userAgent.slice(13).split(';')
os = os[0]
console.log(os)
Windows NT 10.0
Saran Rts
  • 11
  • 1
-1

To get the new Microsoft Edge based on a Mozilla core add:

else if ((verOffset=nAgt.indexOf("Edg"))!=-1) {
 browserName = "Microsoft Edge";
 fullVersion = nAgt.substring(verOffset+5);
}

before

// In Chrome, the true version is after "Chrome" 
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
 browserName = "Chrome";
 fullVersion = nAgt.substring(verOffset+7);
}
frablaser
  • 9
  • 4