I know you should do feature detection where possible, but can you detect in Javascript if the browser is the Microsoft Edge browser?
I maintain an old product and I want to display a warning that some features could be broken without having to invest a lot of time fixing the old code.
The snippet that I have here is also copy from SO too, am sorry that I could not give you reference for the original code, but I have modified it so here it is for those of you looking for snippet to check for IE 11 and MS Edge Window 10:
Here's the simple script to detect Edge browser
Explaination:
A regular expression to search for the string 'Edge' - which we then test against the 'navigator.userAgent' property
The useragent string contains Edge/12.9600, where the 12.9600 is the version number I tested with. This is completely different from the user agent string of Internet Explorer in 'Edge' mode.
User agent string of Edge:
User agent string of IE10 in Edge mode:
So when using javascript, just check for the word 'Edge' in the user agent string. When you also test for other browsers, make sure you check Edge first, otherwise you will get false positives (for example Chrome or Safari...)