469,648 Members | 1,564 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

Using JavaScript to set filter style

74
Hi there!

I've run into a bit of a problem wherein a <div> containing an error message is made invisible by an animation.

I've tried everything to make this <div> reappear on a button click (set the visibility=visible, set the display=block...etc) but nothing seems to be working.

I think the animation is setting a <div>'s opacity to 0. (I can't find out for sure because something magical is done while using the animation in the Ajax.Net toolkit)


I was wondering how to set the following css using javascript:
Expand|Select|Wrap|Line Numbers
  1.    filter:alpha(Opacity=100);
  2.  
I've tried
Expand|Select|Wrap|Line Numbers
  1.  document.getElementById(nameOfDiv).style.filter = 'alpha(Opacity=100)';
  2.  
However, this doesn't work.
I've checked the w3c site for help on setting the Style Object using JavaScript (found here)...and there is no mention of the filter attribute.

Does anyone know how to to do this?

Thanks a lot!
-LilOlMe
Oct 9 '07 #1
4 4957
lilOlMe
74
Yeah that's just wonderful.
Apparently you can set the opacity of the <div> using
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(nameOfDiv).style.filter = 'alpha(Opacity=100)';
This works fine...(I just needed to clear my cache).

Even though this code works fine, I still can't get my <div> to reappear after that .NET Ajax Tool kit animation fades it out!

Gur

-LilOlMe
Oct 9 '07 #2
acoder
16,027 Expert Mod 8TB
filter only works in IE. You can set style.opacity in browsers such as Firefox and Opera.
Oct 10 '07 #3
lilOlMe
74
filter only works in IE. You can set style.opacity in browsers such as Firefox and Opera.
Oh thanks a lot Acoder :D
I didn't know there was an Opacity attribute in CSS....

As it turns out, I was removing the element I needed to refer to in my Server Side code...I completely overlooked it because it seemed to be an Ajax/JavaScript problem at the time...(oops)

Thanks for your help!
Oct 15 '07 #4
drhowarddrfine
7,435 Expert 4TB
Just to make clear what acoder said above. "filter" is not standard CSS and is an IE propietary property. Although 'opacity' is a standard CSS property, IE doesn't work with it while all other modern browsers will. So, to get IE to act like the modern browsers, you have to use both; 'filter' and 'opacity'.
Oct 15 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by John Smith | last post: by
1 post views Thread by Stuart Shay | last post: by
1 post views Thread by gencode | last post: by
6 posts views Thread by Francesco Moi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.