Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fade in & out 1

Status
Not open for further replies.

zbphill

Technical User
Jan 30, 2007
40
US
Can anyone help, I'm trying to get the image to fade out to another picture. But can't get it to work.

<head>
<script type="text/javascript">
function blendimage(divid, imageid, imagefile, millisec) {
var speed = Math.round(millisec / 100);
var timer = 0;

//set the current image as background
document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

//make image transparent
changeOpac(0, imageid);

//make new image
document.getElementById(imageid).src = imagefile;

//fade in image
for(i = 0; i <= 100; i++) {
setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
timer++;
}
}
</script>

</head>

<body>
<a href="javascript:blendimage('blenddiv','blendimage', 'test1.gif',200)">Image 1</a>
<a href="javascript:blendimage('blenddiv','blendimage', 'test2.gif',200)">Image 2</a>
<a href="javascript:blendimage('blenddiv','blendimage', 'test3.gif',200)">Image 3</a>
<div style="background-image: url(test2.gif); background-repeat: no-repeat; width: 100px; height: 100px;" id="blenddiv">
<img src="test2.gif" style="width: 100px; height: 100px; border: 0 none; filter: alpha(opacity=0); -moz-opacity: 0; -khtml-opacity: 0; opacity: 0;" id="blendimage" alt="" />
</div>
</body>

</html>
 
zbphill, maybe try modifying this script I wrote a while back to achieve what you're trying:

thread216-1254421

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Thanks for the help, But your script doesn't work either.
 
Ha, Ha, Just kidden.
I'm an idiot.
This will do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top