Forum Moderators: open

Message Too Old, No Replies

Opacity plus one

         

Adam5000

11:09 pm on Apr 22, 2005 (gmt 0)

10+ Year Member



Teriffic job Orion. You were exactly right. I haven't got the crossbrowser code working yet but this function works great. If I change the opacity in the function, the opacity of the div on the screen changes too. It works just like it should. Great job.

And silly me, what I should have said is, to make the fades work what I need is a function that takes the opacity of a div and adds one percent to it.

And I'm trying to get the cross browser code working because I want to be friendly to netscape users too.

The function below works great, and I need one that takes the opacity of a div and adds one percent to it.

like function changeOpacity() {opacity=opacity+1}. But I know that one won't work.

I know you're probably gone for now Orion and you did a good job.

Can someone help?

<html>
<head>

<DIV id=Image style="position:absolute; left=50; top=50; filter:alpha(opacity=10);">
<IMG src="Files/Image 1.jpg">
</DIV>

</head>

<body>

<SCRIPT language=Javascript>
function changeOpacity()
{document.all.Image.style.filter='alpha(opacity=50)';}

changeOpacity()

</script>

</body>
</html>

orion_rus

11:35 am on Apr 23, 2005 (gmt 0)

10+ Year Member



You need to change this:

var opacity;
function changeOpacity()
{if (opacity<100) {opacity++;}
document.all.Image.style.filter='alpha(opacity='+opacity+')';
document.all.Image.style.MozOpacity=eval(opacity/100);
}

i think all should work when, if you need to change opacity after some time you need to make this
setInterval(changeOpacity,1000);
this will change opacity each second
Good luck to you

Adam5000

4:53 pm on Apr 25, 2005 (gmt 0)

10+ Year Member



Great job Orion. That function does just what I want it to do. I've got some pictures that I want to fade in and fade out and this function does the trick. It works teriffic.