0
我想做一個幻燈片,我剛開始玩網站和幻燈片不工作,我不知道爲什麼。我有固定的我,現在我需要一些幫助,這在所有的錯誤...Javascript幻燈片顯示一點幫助
<head>
<title>Alanna's JavaScript slide show</title>
<script language="JavaScript">
var interval = 1500;
var random_display = 0;
var imageDir = "";
var imageNum = 0;
imageArray = new Array();
imageArray[imageNum++] = new imageItem(imageDir + "01.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "02.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "03.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "04.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "05.jpg");
var totalImages = imageArray.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
function get_ImageItemLocation(imageObj) {
return (imageObj.image_item.src)
}
function randNum(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
imageNum = randNum(0, totalImages - 1);
}
else {
imageNum = (imageNum + 1) % totalImages;
}
var new_image = get_ImageItemLocation(imageArray[imageNum]);
return (new_image);
}
function getPrevImage() {
imageNum = (imageNum - 1) % totalImages;
var new_image = get_ImageItemLocation(imageArray[imageNum]);
return (new_image);
}
function prevImage(place) {
var new_image = getPrevImage();
document[place].src = new_image;
}
function switchImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "switchImage('" + place + "')";
timerID = setTimeout(recur_call, interval);
}
<!--
// -->
</script>
</head>
<body onLoad="switchImage('slideImg1')">
<img name="slideImg1" src="01.jpg" width=500 height=375 border=0>
<img name="slideImg2" src="02.jpg" width=500 height=375 border=0>
<img name="slideImg3" src="03.jpg" width=500 height=375 border=0>
<img name="slideImg4" src="04.jpg" width=500 height=375 border=0>
<img name="slideImg5" src="05.jpg" width=500 height=375 border=0>
<a href="#" onClick="switchImage('slideImg1')">play slide show</a>
<a href="#" onClick="clearTimeout(timerID)"> pause</a>
<a href="#" onClick="prevImage('slideImg'); clearTimeout(timerID)"> previous</a>
<a href="#" onClick="switchImage('slideImg2'); clearTimeout(timerID)">next </a>
</body>
另外,擺脫腳本元素中的HTML註釋分隔符 - t嘿,大約15年或更長時間沒有必要(反正格式不正確)。 – RobG