Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In IE7 it is filter<strong>s</strong> and in IE6 it is filter.</p> <p>The code below returns:</p> <ul> <li>'opacity' if style.opacity is supported</li> <li>'filter' for MS filter ( IE &lt; 7 )</li> <li>'filters' for MS filters ( IE7 )</li> <li>'none' for everything else</li> </ul> <p>.</p> <pre><code>var opacityType=( (typeof o.style.opacity !== 'undefined') ? 'opacity' : /*@cc_on @if (@_jscript) (typeof o.filters === 'object') ? 'filters' : (typeof o.filter === 'string') ? 'filter' : @end @*/ 'none' ); </code></pre> <p>The <a href="http://msdn.microsoft.com/en-us/library/8ka90k2e(VS.85).aspx" rel="noreferrer">@cc&#95;on</a>, <a href="http://msdn.microsoft.com/en-us/library/58dz2w55(VS.85).aspx" rel="noreferrer">@if</a> and <a href="http://msdn.microsoft.com/en-us/library/s59bkzce(VS.85).aspx" rel="noreferrer">@&#95;jscript</a> are used in a <a href="http://msdn.microsoft.com/en-us/library/121hztk3(VS.85).aspx" rel="noreferrer">conditional comment</a> that only IE supports.</p> <p>I have tested this on FF3, IE6, IE7, Opera9 and Chrome 1 but not on IE4,5,or 8.</p> <p>According to <a href="http://www.quirksmode.org/css/opacity.html" rel="noreferrer">quirksmode</a> MS has changed the CSS from <em>filter</em> to <em>-ms-filter</em> so I don't know what result you get with IE8.</p> <p>According to <a href="https://developer.mozilla.org/en/CSS/opacity" rel="noreferrer">mozilla</a> <em><a href="http://www.w3.org/TR/css3-color/#transparency" rel="noreferrer">opacity</a></em> has been supported since FF 0.9, Opera 9 and Safari 1.2 and <em><a href="http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx" rel="noreferrer">filter</a></em> since IE4. </p> <p>I don't like to do browser sniffing, but sometimes it is necessary and conditional comments make it so much easier to handle specific IE things. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload