Forum Moderators: open

Message Too Old, No Replies

Opacity

         

Adam5000

4:17 pm on Apr 22, 2005 (gmt 0)

10+ Year Member



Great group with great people in it.

I'm trying to create a function that will change the opacity of a div.

I've got a sample below and my most recient attempt, but I'm not having much luck.

What I'm trying to do is create fade in and fade out effects by changing the opacity.

This is my most recient attempt.

<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()
{window.document.all.Image.style.opacity=50;}

changeOpacity()

</SCRIPT>

</body>
</html>

But the above function doesn't work. Help.

orion_rus

5:41 pm on Apr 22, 2005 (gmt 0)

10+ Year Member



For better crossbrowsing change this:
<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()
{window.document.all.Image.style.opacity=50;}

to this:
<DIV name="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()
{if (Image.style.MozOpacity) {Image.style.MozOpacity=0.5;}
if (Image.style.filter) {Image.style.filter='alpha(opacity=50)';}}

i think all should be well here)
good luck to you!