本文实例讲述了javascript实现图片循环渐显播放的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:<html>
<title>图片的循环渐显播放效果代码</title>
<head>
<>
<script language=javaScript>
<!--//
sandra0 = new Image();
sandra0.src = "/images/m01.jpg";
sandra1 = new Image();
sandra1.src = "/images/m02.jpg";
sandra2 = new Image();
sandra2.src = "/images/m03.jpg";
var i_strngth=1
var i_image=0
var imageurl = new Array()
imageurl[0] ="/images/m01.jpg"
imageurl[1] ="/images/m02.jpg"
imageurl[2] ="/images/m03.jpg"
function showimage() {
if(document.all) {
if (i_strngth <=110) {
testimage.innerHTML="<img+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+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>
</head>
<body>
<>
<body onLoad="showimage()">
<>
<div id="testimage"></div>
</body>
</html>
希望本文所述对大家的javascript程序设计有所帮助。