Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting Microsoft Edge (Javascript) #167

Open
tyrann0us opened this issue Sep 30, 2015 · 8 comments
Open

Detecting Microsoft Edge (Javascript) #167

tyrann0us opened this issue Sep 30, 2015 · 8 comments
Labels

Comments

@tyrann0us
Copy link

Just a little hint as browserhacks currently doesn't list any hacks for Microsoft Edge:
If you want to target this browser you can combine two rules from IE11:

var isEdge = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style && !window.navigator.msPointerEnabled;

@jeffclayton
Copy link
Collaborator

jeffclayton commented Sep 30, 2015

Hugo - you guys up for making the new browser category? @tyrann0us has a javascript one and here are a few of them in CSS I worked out:

the @supports method: (For all MS Edge = Edge 12+)

@supports (-ms-ime-align:auto) { .selector { property:value; } }

UPDATE: Now that Edge 14 is released, this one works for Edge 12-13 only:

@supports (-ms-accelerator:true) { .selector { property:value; } }

a one-liner selector hack: (For all MS Edge = Edge 12+)

_:-ms-lang(x), _:-webkit-full-screen, .selector { property:value; }

-Jeff

@jeffclayton
Copy link
Collaborator

For the Microsoft Edge browser, the number starts at 12 as they continued the number system past Internet Explorer 11. The stats on the 3 hacks above are all MS Edge 12+ (which actually means all edge browsers). Edge 13 is in beta testing at this time in the dev version of Windows 10.

@jeffclayton
Copy link
Collaborator

For ease of use in this site, considering MS kept the numbers together (MSIE up to 11, Edge 12+) - it may be simplest just to continue the chain as MSIE/EDGE rather than creating a separate category for the time being.

@KittyGiraudel
Copy link
Contributor

@jeffclayton
Copy link
Collaborator

You do realize that is my personal site right? check http://browserstrangeness.com ;)

@jeffclayton
Copy link
Collaborator

jeffclayton commented Apr 13, 2016

I would be happy to start including a lot of them - i just would ask you to add the bitbucket site as a resource site with the few other ones since I have years of time and work invested in it.

@ststeiger
Copy link

Better not to depend on the user agent.
How about:

if (document.documentMode) 
{
    console.log('Hello Microsoft IE User!');
}

if (!document.documentMode && window.msWriteProfilerMark) {
    console.log('Hello Microsoft Edge User!');
}

if (window.msWriteProfilerMark) 
{
    console.log('Hello Microsoft User!');
}

@JStyle21
Copy link

@ststeiger
msWriteProfilerMark isn't there anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants