我有一個完美的代碼,當要旋轉的縮略圖的數量是16並且所有位置都相同時(只是由於縮略圖編號而更改文件的名稱) 。例如:http://www.urltoimage1.jpg....http://www.urltoimage16.jpg在MouseOver中旋轉縮略圖並停止在Mouseleave中旋轉
這是HTML:
<img width="189" height="142" src="http: //www.urltoimage8.jpg" class="someclass" id="latest-499" onmouseover="thumbStart('latest-499', 16, 'http: //www.urltoimage');" onmouseout="thumbStop('latest-499','http: //www.urltoimage8.jpg');">
這裏是JavaScript:
// JavaScript Document
//rotating thumb functions
var rotateThumbs = new Array();
function changeThumb(index, i, num_thumbs, path)
{
if (rotateThumbs[index])
{
if(i<=num_thumbs){
document.getElementById(index).src = path + i + ".jpg";
i++;
setTimeout("changeThumb('"+ index +"'," + i + ", " + num_thumbs + ", '" + path + "')", 600);
}else{
changeThumb(index, 1, num_thumbs, path);
}
}
}
function thumbStart(index, num_thumbs, path)
{
rotateThumbs[index] = true;
changeThumb(index, 1, num_thumbs, path);
}
function thumbStop(index, srco)
{
rotateThumbs[index] = false;
document.getElementById(index).src = srco;
}
現在,問題是一些文章的縮略圖不在同一個位置。例如:http://www.urltoimage1.jpg ... http://www.urltoimageksks16.jpg
我認爲,在這種差異的存在,最好是複製縮略圖的所有網址該類別的圖像,使HTML這樣:
<img width="189" height="142" src="http: //www.urltoimage8.jpg" class="http: //www.urltoimage1.jpg,http: //www.urltoimage2.jpg,...,http: //www.urltoimageksks16.jpg" id="latest-499" onmouseover="thumbStart" onmouseout="thumbStop('latest-499','http: //www.urltoimage8.jpg');">
現在,我在班上img標籤的所有URL,如何能做到這一點的縮略圖旋轉?
感謝