[Html]
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<Html>
<Head>
<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 entry of the array is long, and other items can be customized.
Data = [["3", "a"], ["2", "B"], ["3", "c"], ["2 ", "d"], ["1", ""];
$ (Document). ready (function (){
// Set the trigger event
AutoPlay. run = function (obj, num ){
Back (obj, num );
};
AutoPlay ();
});
Function back (obj, num ){
$ ("# Div_show" cmd.html (obj [num] [1]);
}
Function autoPlay (){
// Initialize counting Parameters
If (autoPlay. num = undefined)
AutoPlay. num = 0;
// Initialization time point
If (autoPlay. timepoint = undefined)
AutoPlay. timepoint = new Date (). getTime ();
If (autoPlay. num <data. length ){
// Function handle, data array, current subscript of autoPlay. num
AutoPlay. run (data, autoPlay. num );
// Play the Array Based on the element length
If (new Date (). getTime ()> autoPlay. timepoint ){
// Determine whether it is the first execution
If (autoPlay. first = undefined)
AutoPlay. first = true;
Else
AutoPlay. num ++;
// Set the next playback time point
AutoPlay. timepoint + = (data [autoPlay. num] [0] * 1000 );
}
SetTimeout ("autoPlay ()", 500 );
}
}
$. Extend ({autoPlay: function (){
Var defaults = {inteval: 500 };
}});
</Script>
</Head>
<Body>
<Div id = "div_show"> </div>
</Body>
</Html>
Defines the playback time and events.