当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript初学者实例教程(10):图像属性

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript初学者实例教程(10):图像属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-10   浏览: 394 ::
收藏到网摘: n/a

实例十

本实例主要介绍了图像属性的使用,模拟百度图片显示

 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图像编程</title>
<script language="javascript">
var imageArray = new Array("/upload/tech/20091009/20091009235222_b83aac23b9528732c23cc7352950e880.jpg","/upload/tech/20091009/20091009235223_73278a4a86960eeb576a8fd4c9ec6997.jpg","/upload/tech/20091009/20091009235223_7634ea65a4e6d9041cfd3f7de18e334a.jpg","/upload/tech/20091009/20091009235223_9766527f2b5d3e95d4a733fcfb77bd7e.jpg","/upload/tech/20091009/20091009235223_0d0871f0806eae32d30983b62252da50.jpg","/upload/tech/20091009/20091009235223_19ca14e7ea6328a42e0eb13d585e4c22.jpg");
var index = 0;
function GetNext()
{
 index++;
 if(index < imageArray.length)  //判断图像的下标是否小于数组的长度
 {
  document.images["saint"].src=imageArray[index]; //如果小于,那么就显示该下标所指定的图像
 }
 else
 {
  index = 0;
  document.images["saint"].src=imageArray[index]; //如果不小于,那么就显示第一幅图像,并把index值置为0 
 }
}
function GetPrev()
{
 index--;
 if(index >= 0) //判断图像的下标是否大于0
 {
  document.images["saint"].src=imageArray[index]; //如果大于,那么就显示该下标所指定的图像
 }
 else
 {
  index = imageArray.length-1;
  document.images["saint"].src=imageArray[index];  //如果不大于,那么就显示最后一幅图像,并把index值置为数组长度减1 
 }
}
</script>
</head>
<body>
<img name="saint" src="/upload/tech/20091009/20091009235222_b83aac23b9528732c23cc7352950e880.jpg" width="400" height="300">
<br>
<a href="javascript:GetNext()">下一幅</a>
<a href="javascript:GetPrev()">上一幅</a>
</body>
</html>

效果演示:


[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]