Jump to content

[SOLVED] css3 standard opacity in javascript


gli

Recommended Posts

Hi! First, im begginer to JavaScript.

I have script that force opacity from max to nothing.

I use two opacities,   one for ie: opacity  and  css3 standard filter:alpha(opacity=x).

All is ok with 'opacity' , but with second css3 standard is problem,  i dont know if i add it right in my JavaScript because of continue after the word 'filter:' ,   first one is just simple 'opacity'

So there is the code:

 

var opacity2 = 100

function fadeout2() {

   if(opacity2 >= 1) {

       opacity2 = opacity2 - 10;

       document.getElementById('box2').style.filter='alpha(opacity=' + opacity2 + ')';

       window.setTimeout('fadeout2()', 60);

   } else {

       document.getElementById('box2').style.visibility="active";

   }
} 

 

and here is code for 'opacity'  which are working

 

var opacity = 1

function fadeout() {

   if(opacity >= 0.1) {

       opacity = opacity - 0.1;

       document.getElementById('box2').style.opacity=opacity;

       window.setTimeout('fadeout()', 60);

   } else {

       document.getElementById('box2').style.visibility="hidden";

   }
} 

 

 

 

Thanks and sorry for my bad English.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.