62
votes

I'm making a website and I want it to be compatible with the forthcoming Microsoft Edge when it comes out officially. To be more specific, the mobile version of it. Does anyone know what string will identify the Edge Mobile Browser (for example, "IE Mobile" identifies the mobile version of the Internet Explorer).

10
If you want it to be compatible, focus more on standards than user-agent strings. Microsoft Edge is built to handle the web similar to Firefox and Chrome. As always, use feature-detection, progressive-enhancement, and test cross-browser early, and often.Sampson
It's "IEMobile" that usually identifies IE on a windows phone (not "IE Mobile" ;-)). Though note that the newest windows phones (e.g. Lumia 950XL) use "Edge" and dont have the "IEMobile" identifier any more eitherbytedev

10 Answers

98
votes

Microsoft Edge UA string:

Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136

I detail why in this blog post.

Neowin recently reported that Microsoft’s new browser for Windows 10, Spartan, uses the Chrome UA string, “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0″. That is done on purpose.

You’ll also notice that the entire string ends with “Edge/12.0″, which Chrome does not.

I should point out, that this isn’t a radical departure from what Microsoft did with IE 11, which on Windows 8 reads: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko, as explained in this post.

What is User Agent sniffing?

Often, web developers will UA sniffing for browser detection. Mozilla explains it well on their blog:

Serving different Web pages or services to different browsers is usually a bad idea. The Web is meant to be accessible to everyone, regardless of which browser or device they’re using. There are ways to develop your web site to progressively enhance itself based on the availability of features rather than by targeting specific browsers.

Here’s a great article explaining the history of the User Agent.

Often, lazy developers will just sniff for the UA string and disable content on their website based on which browser they believe the viewer is using. Internet Explorer 8 is a common point of frustration for developers, so they will frequently check if a user is using ANY version of IE, and disable features.

The Edge team details this even deeper on their blog.

All user agents strings contain more information about other browsers than the actual browser you are using – not just tokens, but also ‘meaningful’ version numbers.

Internet Explorer 11’s UA string:

Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko

Microsoft Edge UA string:

Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136

The userAgent property has been aptly described as “an ever-growing pack of lies” by Patrick H. Lauke in W3C discussions. (“or rather, a balancing act of adding enough legacy keywords that won’t immediately have old UA-sniffing code falling over, while still trying to convey a little bit of actually useful and accurate information.”)

We recommend that web developers avoid UA sniffing as much as possible; modern web platform features are nearly all detectable in easy ways. For example, the Modernizr library is a fantastic and simple way of detecting features.

Over the past year, we’ve seen some UA-sniffing sites that have been updated to detect Microsoft Edge… only to provide it with a legacy IE11 code path. This is not the best approach, as Microsoft Edge matches ‘WebKit’ behaviors, not IE11 behaviors (any Edge-WebKit differences are bugs that we’re interested in fixing).

In our experience Microsoft Edge runs best on the ‘WebKit’ code paths in these sites. Also, with the internet becoming available on a wider variety of devices, please assume unknown browsers are good – please don’t limit your site to working only on a small set of current known browsers. If you do this, your site will almost certainly break in the future.

Conclusion

By presenting the Chrome UA string, we can work around the hacks these developers are using, to present the best experience to users.

12
votes

There is an MDN article about browser detection using the "User-Agent" and what you should have in mind when do something like that.

Independent of that the MSDN Library describes the user-agent changes for "Edge".

From the MSDN User-agent string changes page:

Microsoft Edge for Windows 10 Mobile Insider Preview has the following user-agent string:

Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.<OS Build #>

8
votes

For those looking for a regex to detect IE and Microsoft Edge, I repurposed one from another SO answer and added Edge

/(?:\b(MS)?IE\s+|\bTrident\/7\.0;.*\s+rv:|\bEdge\/)(\d+)/

I made it check for Edge and then a miscellaneous digit in case they decide to iterate the Edge version.

EDIT: To update yes, both Edge and older IE versions are considered very different browsers. My use case required detecting IE branded browsers for marketing purposes (if user is using any Internet Explorer/Edge browser, we wanted to show something for that) but that might not necessarily be the case for you.

2
votes

Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0

2
votes

Currently Web agent isn't the key point to adapt your site but you should detect browser features.

For that matter, you should use some library like Modernizr to check for specific browser features independently of what browser vendor or version is using the user.

Note: Despite of downvotes, everyone should review the other answer on this Q&A which extensively explains what's behind my summarized answer where the answer provides proves that many browser vendors discourages doing user-agent sniffing. That's the reason behind my own answer, where I suggest everyone to adapt their sites based on features rather than a specific browser.

2
votes

You forgot SA's need to know browser type to report that to mgmt. It's got to be clear what browser is being used, for accuracy. And on a clean build the Edge user agent has no "EDGE" keyword:

Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)

1
votes

you can always check the User-Agent-string by

  1. pressing F12 for the developer tools
  2. Tabulator: Console
  3. type: "navigator.userAgent" + hit return

works in IE, Edge, Chrome..

In IE and Edge you can simply overwrite it for the current windows on the Tabulator:Emulation, field "User agent string" and select "custom"...

1
votes

You can find the most recent User Agent (UA) String at https://docs.microsoft.com/en-us/microsoft-edge/web-platform/user-agent-string. At the time of writing, it was

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43.

Funny enough, it also worked for me when taking just Mozilla/5.0.

1
votes

User Agent Overrides

Sometimes, a website does not recognize the updated version of the Microsoft Edge UA. As a result, a set of the features of that website may not work correctly. When Microsoft is notified about these types of issues, website owners are contacted and informed about the updated UA.

The sites often need some time to update and test the UA detection logic to address the issues that Microsoft reports to site owners. In these cases, Microsoft uses a list of UA overrides in our Beta and Stable channels to maximize compatibility for users who access these sites. The overrides specify new UA values that Microsoft Edge should send instead of the default UA for specific sites. You are able to view the list of UA overrides that are currently being applied by navigating to edge://compat/useragent in the Beta and Stable channels of Microsoft Edge.

Go to this page for more detail about User Agent String

-1
votes

User-Agent

The User-Agent request header is a characteristic string that lets servers and network peers identify the application, operating system, vendor, and/or version of the requesting user agent.

Syntax

User-Agent: <product> / <product-version> <comment>

Common format for web browsers:

User-Agent: Mozilla/5.0 (<system-information>) <platform> (<platform-details>) <extensions>

Go to this page for more detail about User Agent String