复制代码 代码如下:
<%@LANGUAGE="JAVASCRIPT"CODEPAGE="936"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>图片对象</title>
<scriptlanguage="javascript">
<>
</script>
</head>
<bodyonload="MM_preloadImages('img/3.jpg','img/2.jpg','img/4.jpg')">
<p><strong>演示一:无刷新变换图片(有点歪)</strong></p>
<p>
<selectname="select1"onchange="img(this.options.selectedIndex)">
<optionvalue="img1">1</option>
<optionvalue="img2">2</option>
<optionvalue="img3">3</option>
<optionvalue="img4">4</option>
</select>
<inputtype="image"name="img"src="img/7.jpg"/>
</p>
<p><strong>演示二:鼠标触发图片变换(书面名称好像叫图像滚动)</strong></p>
<p>
<scriptlanguage="javascript">
//先建立两个数组,一组是on状态的,一组是off状态的
//数组使用的是字符串作索引,一来方便识别,二来在代码运行中不会冲突
offimg=newArray()
offimg["play"]=newImage(60,50)
offimg["stop"]=newImage(60,50)
offimg["pause"]=newImage(60,50)
offimg["rewind"]=newImage(66,55)
//赋值
offimg["play"].src="img/1.jpg"
offimg["stop"].src="img/2.jpg"
offimg["pause"].src="img/3.jpg"
offimg["rewind"].src="img/4.jpg"
//第二个数组
onimg=newArray()
onimg["play"]=newImage(60,50)
onimg["stop"]=newImage(60,50)
onimg["pause"]=newImage(60,50)
onimg["rewind"]=newImage(66,55)
//赋值
onimg["play"].src="img/5.jpg"
onimg["stop"].src="img/6.jpg"
onimg["pause"].src="img/7.jpg"
onimg["rewind"].src="img/1.jpg"
functionon(imgname){
if(document.images){//判断浏览器是否能够处理图片对象
document.images[imgname].src=onimg[imgname].src//将对应的图片对象的src值赋给图片
}
}
functionoff(imgname){
if(document.images){//判断浏览器是否能够处理图片对象
document.images[imgname].src=offimg[imgname].src//将对应的图片对象的src值赋给图片
}
}
functionsetmsg(msg){//改变状态栏提示
window.status=msg;
returntrue;
}
</script>
<tablewidth="591"border="1">
<tr>
<tdwidth="169"><tableborder="0"cellpadding="0"cellspacing="0">
<tr>
<td><ahref="http://thcjp.cnblogs.com"target="_top"onclick="MM_nbGroup('down','group1','Blogs','img/3.jpg',1)"onmouseover="MM_nbGroup('over','Blogs','img/2.jpg','img/4.jpg',1)"onmouseout="MM_nbGroup('out')"><imgsrc="img/1.jpg"alt="田轰穿博客"name="Blogs"width="80"height="120"border="0"id="Blogs"onload=""/></a></td>
</tr>
</table>
<p><ahref="http://thcjp.cnblogs.com">上面是DW做的<br/>
是预载入图片</a></p></td>
<tdwidth="406">
<ahref="http://thcjp.cnblogs.com"><imgsrc="img/1.jpg"width="80"height="120"border="0"name="play"onMouseOver="on('play');returnsetmsg('我的教程博客-->http://thcjp.cnblogs.com')"onmouseout="off('play');returnsetmsg('');"/></a>
<ahref="http://www.cnblogs.com/thcjp/category/65304.html"><imgsrc="img/2.jpg"width="80"height="120"border="0"name="stop"onmouseover="on('stop');returnsetmsg('天轰穿的博客之js入门系列教程-->http://www.cnblogs.com/thcjp/category/65304.html')"onmouseout="off('stop');returnsetmsg('')"/></a>
<ahref="http://www.cnblogs.com/thcjp/category/59325.html"><imgsrc="img/3.jpg"width="80"height="120"border="0"name="pause"onmouseover="on('pause');returnsetmsg('VS2005控件系列教程http://www.cnblogs.com/thcjp/category/59325.html')"onmouseout="off('pause');returnsetmsg('')"/></a>
<ahref="http://thcjp.cnblogs.com"><imgsrc="img/4.jpg"width="80"height="120"border="0"name="rewind"onmouseover="on('rewind');returnsetmsg('ajax系列视频教程-->http://thcjp.cnblogs.com')"onmouseout="off('rewind');returnsetmsg('');"/></a></td>
</tr>
</table>
</body>
</html>