当前位置: 代码迷 >> JavaScript >> 有人会渐变轮换的js代码吗,该如何处理
  详细解决方案

有人会渐变轮换的js代码吗,该如何处理

热度:110   发布时间:2012-03-13 11:21:12.0
有人会渐变轮换的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>
  相关解决方案