我正在编写一个简单的图像滑块,我的问题是当它到达滑块的末端时它会停止。我需要的是在滑块的末尾继续,它将显示滑块中的第一个图像并继续滑动直到 onKeyup 事件触发......
任何帮助表示赞赏:)
这是我的代码:
var second_array = new Array();
function LoadImageList() {
var s = "";
var ia = 0;
var std = "";
var etd = "";
var paths = FSO.OpenTextFile("bin\\Tlist.txt")
while (!paths.AtEndOfStream) {
var tot = ia++;
content = paths.ReadLine();
var newNameN = content.split(";");
var curID = "t"+tot
var forID = "t"+parseFloat(tot+1)
var bacID = "t"+parseFloat(tot-1)
second_array[tot] = "<td nowrap style=\"padding:10px;\"><font style=\"display:none;\">"+newNameN[0]+"</font><img src=\""+newNameN[2]+"\\folderS.jpg\" id=\""+curID+"\" tabindex=\""+tot+"\" style=\"width:217px; height:322px; border:solid 5px silver; border-radius:10px; box-shadow: 0 0 15px #fff; cursor: pointer;\" onMouseOver=\"this.style.border='solid 5px red';\" onMouseOut=\"this.style.border='solid 5px silver';\"></td>";
}
second_array.sort();
var tempList = second_array.join("");
thumb.innerHTML = "<table cellpadding=0 cellspacing=0 border=0><tr>"+tempList+"</tr></table>";
}
var defaultStep=1;
var step=defaultStep;
var timerLeft;
var timerRight;
function scrollDivLeft(id) {
document.getElementById(id).scrollLeft+=Math.round(step*100);
timerLeft=setTimeout("scrollDivLeft('"+id+"')",1);
}
function scrollDivRight(id) {
document.getElementById(id).scrollLeft-=Math.round(step*100);
timerRight=setTimeout("scrollDivRight('"+id+"')",1);
}
document.body.addEventListener('keydown', function (e) {
if (e.keyCode=='37') {
clearTimeout(timerRight);
scrollDivRight("thumb");
}
else if (e.keyCode=='39') {
clearTimeout(timerLeft);
scrollDivLeft("thumb");
}
})
document.body.addEventListener('keyup', function (e) {
if (e.keyCode=='37') {
clearTimeout(timerRight);
}
else if (e.keyCode=='39') {
clearTimeout(timerLeft);
}
})