码迷,mamicode.com
首页 > Web开发 > 详细

自学篇之---js最简单的幻灯片

时间:2015-02-08 23:27:56      阅读:422      评论:0      收藏:0      [点我收藏+]

标签:

<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>



































自学篇之---js最简单的幻灯片

标签:

原文地址:http://my.oschina.net/tianyuqin/blog/376541

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!