faqts : Computers : Programming : Languages : JavaScript : Images

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 24 people (71%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

how can I use Opacity (fade effect) in my blocks (myphpnuke website)?

Feb 10th, 2003 02:39
Klaus Bolwin, remco de leeuw,


opacity is a style property which will come up in CSS3. However Mozilla
has got an extension to CSS2, which will allow the Gecko-based browsers
to set opacity with CSS2:
e.g.
div.opac {-moz-opacity:0.5;}
also %-values are allowed (-moz-opacity:50%;}, however (I think)
Netscape 6.2 had got problems with this notation.
in MSIE you have to use the alpha filter:
e.g.
div.opac {filter:Alpha(opacity=2);}
You can change the opacity in Mozilla / Netscape6+ and using the
MozOpacity property of the elements style. In MSIE you can do it using
the alpha-filter again:
function ChangeOpac (start,end,step,speed)
  {
  if (start < end)
    {
    start += step
    if (!document.all)
        {document.getElementById(ziel3).style.MozOpacity = start/100;}
    else
        {ziel = eval("document.all." + ziel3);
ziel.filters.alpha.opacity = start;}
   setTimeout ("ChangeOpac("+start+","+end+","+step+","+speed+")",speed);
     }
   }
Whereas changing the opacity makes no problems in Mozilla&Co, in MSIE,
the filter:alpha must be set by CSS prior to any changes with javascript
And unfortuneately the filter can be applied to images only, it is not
working with HTML-Elements like div's.