图像察看器

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. myImages=new Array()
  5. myImages[0]="/i/eg_mouse.jpg"
  6. myImages[1]="/i/eg_smile.gif"
  7. myImages[2]="/i/eg_landscape.jpg"
  8. myImages[3]="/i/eg_landscape2.jpg"
  9. myImages[4]="/i/eg_landscape3.jpg"
  10. myImages[5]="/i/eg_greanfoliage.jpg"
  11. imagecounter=myImages.length-1
  12. i=0
  13.  
  14. function first()
  15. {
  16. document.getElementById('imageviewer').src=myImages[0]
  17. i=0
  18. }
  19.  
  20. function previous()
  21. {
  22. if (i>0)
  23. {
  24. i--
  25. document.getElementById('imageviewer').src=myImages[i]
  26. }
  27. }
  28.  
  29. function next()
  30. {
  31. if (i<imagecounter)
  32. {
  33. i++
  34. document.getElementById('imageviewer').src=myImages[i]
  35. }
  36. }
  37.  
  38. function last()
  39. {
  40. document.getElementById('imageviewer').src=myImages[imagecounter]
  41. i=imagecounter
  42. }
  43. </script>
  44. </head>
  45.  
  46. <body>
  47. <center>
  48. <form>
  49. <input type="button" value="First" onclick="first()">
  50. <input type="button" value="Previous" onclick="previous()">
  51. <input type="button" value="Next" onclick="next()">
  52. <input type="button" value="Last" onclick="last()">
  53. </form>
  54. <img id="imageviewer" src="/i/eg_mouse.jpg" />
  55. </center>
  56. </body>
  57. </html>