Resources

Image opacity & JavaScript

script written by

Description:

This script will take an image and gradually fade it in and out using image opacity and Javascript.

<!-- Image fading script http://www.designplace.org. -->
<!-- written by tux tux@designplace.org -->
<!-- change image id, path and dimensions below to your image dimensions! -->

<img id="tuxie" src="path/images.gif" width=116 height=123
 style="-moz-opacity:30%;filter:alpha(opacity=30)">

<script>
value=0
var plus=1
var minus=0

function IE(){
if (value<80&&plus)
value+=5
else{
plus=0
minus=1
}

if (value>30&&minus)
value-=5
else{
plus=1
minus=0
}

document.getElementById("tuxie").filters[0].opacity=value
}


function MOZ()
{
if (value<80&&plus)
value+=5
else{
plus=0
minus=1
}

if (value>30&&minus)
value-=5
else{
plus=1
minus=0
}

document.getElementById("tuxie").style.MozOpacity=value+"%"
}

if (window.sidebar)
{
setInterval("MOZ()",200)
}

if (document.all)
{
setInterval("IE()",200)
}
</script>

Preview script (new window) | Download code



Remember, if you get stuck or need to ask any questions, register with the forums and tell us about it!


Warning: include(includes/ads.php): failed to open stream: No such file or directory in /home1/design/public_html/scripts.php on line 130

Warning: include(includes/ads.php): failed to open stream: No such file or directory in /home1/design/public_html/scripts.php on line 130

Warning: include(): Failed opening 'includes/ads.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home1/design/public_html/scripts.php on line 130


le>