日期:2014-05-16  浏览次数:20310 次

有人会渐变轮换的js代码吗
图片可以渐变显示,并且播放过程中而已停止,继续播放功能.

------解决方案--------------------
<html>
<style>
</style>
<script>
window.onload=initPicPlayer;
function initPicPlayer(){
var urls=[ "01.jpg ", "02.jpg ", "03.jpg ", "04.jpg "];
var tag=document.getElementById( "player ");
window.player=new picPlayer(tag,urls);
window.player.start();
}
function picPlayer(img,urls){
this.urls=urls;
this.tag=img;
this.tag.src=this.urls[0];
this.next=1;
this.start=function(){
this.timer=window.setInterval( "window.player.change() ",3000);
}
this.stop=function(){
clearInterval(this.timer);
}
this.change=function(){
this.tag.src=this.urls[this.next%this.urls.length];
this.next++;
}
}
function control(btn){
if(btn.value== "Stop "){
btn.value= "Play ";
window.player.stop();
}else{
btn.value= "Stop ";
window.player.start();
}
}
</script>
<body>
<img id= "player " />
<input type= "button " value= "Stop " onclick= "control(this) " />
</body>
</html>