admin管理员组

文章数量:1334919

In my web-app I am using a transparent blur filter to overlay on top of a video. This is doable with all browsers except IE10/11. Since the blur filter is a CSS property, I can't really do proper feature detection, as I should be doing. Instead, I am using this:

if(navigator.userAgent.indexOf("Trident")>-1) { // IE ... }

If IE is detected, I use a different filter (non-blur) that works there.

Is there any situation in which this code might give a false positive? Are there any blur-patible browsers that use the Trident engine?

Edit: I know IE8 and IE9 have their own blur filters, but for consistency's sake, we decided to use the same alternative filter for all versions of IE.

In my web-app I am using a transparent blur filter to overlay on top of a video. This is doable with all browsers except IE10/11. Since the blur filter is a CSS property, I can't really do proper feature detection, as I should be doing. Instead, I am using this:

if(navigator.userAgent.indexOf("Trident")>-1) { // IE ... }

If IE is detected, I use a different filter (non-blur) that works there.

Is there any situation in which this code might give a false positive? Are there any blur-patible browsers that use the Trident engine?

Edit: I know IE8 and IE9 have their own blur filters, but for consistency's sake, we decided to use the same alternative filter for all versions of IE.

Share Improve this question edited Feb 10, 2014 at 23:09 sg asked Feb 10, 2014 at 20:13 sgsg 1,82620 silver badges41 bronze badges 3
  • 1 I believe you can use modernizr. to check for CSS filters support – Yuriy Galanter Commented Feb 10, 2014 at 20:18
  • I agree in principle with Yuriy, that modernizr (or the approach of testing for that feature) makes more sense then checking against the UA. However, loading modernizr, just to test for the blur filter may be overkill (especially if you're not using it in your current project). Did you consider a test like: if(document.documentElement.style.msFilter) ... (msFilter, webkitFilter, etc.) // Do something – Jack Commented Feb 10, 2014 at 20:28
  • Thanks for the ment, Jack! So, according to your answer, it is possible to detect whether specific styles are available in the current browser using Javascript? Please elaborate if it is so, I would definitely prefer using feature detection over gross browser detection. Edit: No, I am not using modernizr. Blur is the only browser-dependent feature I am trying to keep track of, so yes, loading it would be too much. – sg Commented Feb 10, 2014 at 20:41
Add a ment  | 

2 Answers 2

Reset to default 5

This page explains the user agent strings used by Internet explorer:

http://msdn.microsoft./library/ms537503.aspx

It says that the Trident token was only introduced in IE8, so you might want to check for "MSIE" instead or as well.

There is also this page:

http://msdn.microsoft./en-US/library/ms537509.aspx

which is "archived and is no longer actively maintained" but does include a lot of useful information on detecting Internet Explorer.

You can detect filter support, as described in the answer to this question: How can I feature-detect CSS filters?

本文标签: javascriptDetecting IE by looking for quotTridentquot stringStack Overflow