<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>auto play</title>
<script type= "Text/javascript" src= ". /jquery-1.8.0.min.js "/></script>
<script type= "Text/javascript" >
The first item of the array is long and other items can be customized
data = [[[3], "a"],["2", "B"],["3", "C"],["2", "D"],["1", ""]];
$ (document). Ready (function () {
Setting Trigger Events
Autoplay.run = function (obj,num) {
Back (Obj,num);
};
AutoPlay ();
});
function back (obj,num) {
$ ("#div_show"). html (obj[num][1]);
}
function AutoPlay () {
Initialization count parameters
if (Autoplay.num ==undefined)
Autoplay.num = 0;
Initialize point of Time
if (Autoplay.timepoint ==undefined)
Autoplay.timepoint = new Date (). GetTime ();
if (autoplay.num<data.length) {
function handle, data array, autoplay.num current subscript
Autoplay.run (Data,autoplay.num);
Play array by element time length
if (new Date (). GetTime () >autoplay.timepoint) {
Determine whether the first execution
if (autoplay.first==undefined)
Autoplay.first = true;
Else
autoplay.num++;
Set the time point for the next playback
Autoplay.timepoint + = (data[autoplay.num][0]*1000);
}
SetTimeout ("AutoPlay ()", 500);
}
}
$.extend ({autoplay:function () {
var defaults = {inteval:500};
}});
</script>
<body>
<div id= "Div_show" ></div>
</body>