图片的渐显渐隐播放

 

点击这里看效果


在 <head> 与 </head> 之间加入:

<SCRIPT language=javaScript>
sandra0 = new Image();
sandra0.src = "../images/5dcity.jpg";

var i_strngth=1
var i_image=0
var imageurl = new Array()
imageurl[0] ="../images/5dcity.jpg"
function showimage() {
if(document.all) {
if (i_strngth <=110) {
testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
i_strngth=i_strngth+10
var timer=setTimeout("showimage()",100)
}
else {
clearTimeout(timer)
var timer=setTimeout("hideimage()",1000)
}
}
if(document.layers) {
clearTimeout(timer)
document.testimage.document.write("<img src="+imageurl[i_image]+" border=0>")
document.close()
i_image++
if (i_image >= imageurl.length) {i_image=0}
var timer=setTimeout("showimage()",2000)
}
}
function hideimage() {
if (i_strngth >=-10) {
testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
i_strngth=i_strngth-10
var timer=setTimeout("hideimage()",100)
}
else {
clearTimeout(timer)
i_image++
if (i_image >= imageurl.length) {i_image=0}
i_strngth=1
var timer=setTimeout("showimage()",500)
}
}
</SCRIPT>

在 <body> 与 </body> 之间加入:

<DIV id=testimage style="LEFT: 51px; VISIBILITY:
visible; POSITION: absolute; TOP: 118px;
width: 21px; height: 12px"></DIV>

把 <body> 改为 <BODY onload=showimage()>