自学篇之---js最简单的幻灯片
<html>
<head>
<script type="text/javascript">
myImages=new Array()
myImages[0]="/i/eg_mouse.jpg"
myImages[1]="/i/eg_smile.gif"
myImages[2]="/i/eg_landscape.jpg"
myImages[3]="/i/eg_landscape2.jpg"
myImages[4]="/i/eg_landscape3.jpg"
myImages[5]="/i/eg_greanfoliage.jpg"
imagecounter=myImages.length-1
i=0
function first()
{
document.getElementById(‘imageviewer‘).src=myImages[0]
i=0
}
function previous()
{
if (i>0)
{
i--
document.getElementById(‘imageviewer‘).src=myImages[i]
}
}
function next()
{
if (i<imagecounter)
{
i++
document.getElementById(‘imageviewer‘).src=myImages[i]
}
}
function last()
{
document.getElementById(‘imageviewer‘).src=myImages[imagecounter]
i=imagecounter
}
function scroll(){
if(i<imagecounter){
i++
document.getElementById(‘imageviewer‘).src=myImages[i]
timer=setTimeout("scroll()",1000)
}
if(i==imagecounter){
i=0
}
}
function stop(){
clearTimeout(timer)
}
</script>
</head>
<body onload="scroll()" onunload="stop()">
<center>
<form>
<input type="button" value="First" onclick="first()">
<input type="button" value="Previous" onclick="previous()">
<input type="button" value="Next" onclick="next()">
<input type="button" value="Last" onclick="last()">
</form>
<img id="imageviewer" src="/i/eg_mouse.jpg" />
</center>
</body>
</html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。