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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.