Copy codeThe Code is as follows:
<Script language = javascript>
Var curIndex = 0;
// Time interval (MS)
Var timeInterval = 1000;
Var arr = new Array ();
Arr [0] = "1.jpg ";
Arr [1] = "2.jpg ";
Arr [2] = "3.jpg ";
Arr [3] = "4.jpg ";
Arr [4] = "5.jpg ";
Arr [5] = "6.jpg ";
Arr [6] = "7.jpg ";
SetInterval (changeImg, timeInterval );
Function changeImg ()
{
Var obj = document. getElementById ("obj ");
If (curIndex = arr. length-1)
{
CurIndex = 0;
}
Else
{
CurIndex + = 1;
}
Obj. src = arr [curIndex];
}
</Script>
You can configure the time interval for switching each image, and set the path of each image (either absolute or relative)
Although very simple, it is very practical.
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> automatic image jump </title>
<Script language = "javascript">
SetInterval (test, 1000 );
Var array = new Array ();
Var index = 0;
Var array = new Array ("image/1.jpg"," image/2.jpg", "image/3.jpg"," image/4.jpg", "image/5.jpg"," image/6.jpg ", "image/7.jpg"," image/8.jpg", "image/9.jpg"," image/10.jpg ");
Function test ()
{Var myimg = document. getElementById ("imgs ");
If (index = array. length-1)
{Index = 0 ;}else {index ++ ;}
Myimg. src = array [index];
}
</Script>
</Head>
<Body>
</body>
</Html>