所以我试图制作一个简单的图像"目录"在哪里我可以循环一些图像。这是代码: http://pastebin.com/raw/NDh4VBtz 我现在面临两个问题:
文件的JavaScript部分:
<script type="text/javascript">
var Images =
new Array("first.jpg", "second.jpg", "third.jpg", 0)
function imagesS(ImageId, TxtId, ImageArr, Direction) {
IndPos = 0;
if (Direction == "+1"){
IndPos += 1;
if (ImageArr.length == IndPos) {
alert("Last photo!");
} else {
document.getElementById(ImageId).src= ImageArr[IndPos];
document.getElementById(TxtId).innerHTML = "Text: <i>" + ImageArr[IndPos] + "</i>";
}
} else if (Direction == "-1"){
IndPos -= 1;
if (IndPos == "0" || IndPos == "-1"){
alert("Can't do that!");
} else {
document.getElementById(ImageId).src= ImageArr[IndPos];
document.getElementById(TxtId).innerHTML = "Text: <i>" + ImageArr[IndPos] + "</i>";
}
}
}