javascript学习(5):建立循环式幻灯片,可控制的点选显示的图片



页面显示,可控制的点选要显示的内容

<!DOCTYPE html>
<html>
<head>
<title>Image Slideshow</title>
<script src="script09.js"></script>
<link rel="stylesheet" href="script01.css">
</head>
<body>
<div class="centered">
<h1>Welcome, Robot Overlords!</h1>
<img src="image/1.jpg" id="myPicture" width="200" height="400" alt="Slideshow">
<h2><a href="previous.html" id="prevLink">&lt;&lt; Previous </a>&nbsp;&nbsp;<a href="next. html"id="nextLink">Next &gt;&gt;</a></h2>
</div>
<script>
window.onload = initAll;
function initAll(){
	document.getElementById("prevLink").onclick = prev;
	document.getElementById("nextLink").onclick = next;
}
var t = 0;
var arr = new Array("image/2.jpg","image/3.jpg","image/1.jpg");
function prev(){
	if(t==0){
		t = arr.length;
	}
	t--;
	document.getElementById("myPicture").src = arr[t];
	return false;
}
function next(){
	t++;
	if(t==arr.length){
		t=0;
	}
	document.getElementById("myPicture").src = arr[t];
	return false;
}
</script>
</body>
</html>

你可能感兴趣的:(JavaScript)