VK wrote:
> On Nov 19, 10:38 pm, Darko <darko.maksimo...@gmail.com> wrote:
>> As for getting the
>> element's opacity, I have the following (not working) lines of code:
>>
>> if ( targetObject.filters && targetObject.filters.length > 0 )
>> opacity =
>> targetObject.filters.item("DXImageTransform.Micros oft.Alpha").Opacity;
>>
>> Setting it, I tried:
>>
>> if ( targetObject.filters && targetObject.filters.length > 0 )
>> targetObject.setAttribute( "style", "filter: alpha(opacity=" +
>> opacity + ")" );
>>
>> None work. I have digged these out from some MSDN article
>
> Do you still remember which one?
Probably
http://msdn2.microsoft.com/en-us/lib...ipting_Filters or
a previous version.
>> but they
>> aren't working, at least they don't work in to me available IE 6.0.
>
> Of course they don't: setAttribute method has nothing to do with it.
To be precise, setAttribute() does not seem to work there *for IE*.
>> Do you have better (i.e. working) ways of yours?
>
> Not mine, but tested working:
>
> http://www.quirksmode.org/js/opacity.html
However, it does not make sense in passing ranges from 0 to 10 and then
computing the required value twice. With the division for `opacity', there
is even a rounding error involved, needlessly. It makes more sense have
`value' range from 0 to 1 (thereby to pass the percentage x% as 0.0x to the
function); the computation will have to be done only once (for `filter'),
and the used values will be as exact as the layout engine allows it:
function setOpacity(value)
{
testObj.style.opacity = value;
testObj.style.filter = 'alpha(opacity=' + value * 100 + ')';
}
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$>