Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

What's the best way to detect IE?

Some people are saying use Modernizr, some say use 'conditional comments', and all kinds of other functions.

I need to target IE with specific jQuery as our project is very HTML5 video heavy and IE and Windows 8 has a real conflict at the moment with Flash - and yes we tried setting the mime types in htaccess - this issue is with some installations of Windows 8 and 8.1.

Thank you .

Kind regards, Michael

At the moment we're using this and it appears to be working

var isIE = false;
    if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
        isIE = true;   
    }

1 Answer

Microsoft would tell you to detect browser features and not browser versions, https://msdn.microsoft.com/en-us/library/hh273397(v=vs.85).aspx. They almost appear to mangle their User-Agent string making detection a pain. The script your using is probably fine for this case I'd imagine - if it's working stick with it I'd say.

Ah ok, thanks Stephen