js自動再生のインスタンスコード
2229 ワード
br>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
auto play
<br> // ,
<br> data = [["3","a"],["2","b"],["3","c"],["2","d"],["1",""]];
<br>
<br> $(document).ready(function(){
<br> //
<br> autoPlay.run = function(obj,num){
<br> back(obj,num);
<br> };
<br> autoPlay();
<br> });
<br>
<br> function back(obj,num){
<br> $("#div_show").html(obj[num][1]);
<br> }
<br>
<br> function autoPlay(){
<br> //
<br> if(autoPlay.num ==undefined)
<br> autoPlay.num = 0;
<br> //
<br> if(autoPlay.timepoint ==undefined)
<br> autoPlay.timepoint = new Date().getTime();
<br> if(autoPlay.num<data.length){
<br> // ,data ,autoPlay.num
<br> autoPlay.run(data,autoPlay.num);
<br> //
<br> if(new Date().getTime()>autoPlay.timepoint){
<br> //
<br> if(autoPlay.first==undefined)
<br> autoPlay.first = true;
<br> else
<br> autoPlay.num++;
<br> //
<br> autoPlay.timepoint += (data[autoPlay.num][0]*1000);
<br> }
<br> setTimeout("autoPlay()",500);
<br> }
<br> }
<br>
<br> $.extend({autoPlay:function(){
<br> var defaults = {inteval:500};
<br> }});
<br>
<br>
再生時間の定義、イベントの定義