图片的浏览,经常会看见在图片的左边点一下转到上一张图片,点右边一下,转到下一张图片,而且鼠标在左边时鼠标是向左的方向,鼠标在右边时鼠标是向右方向。以下示例是用html做的静态的形式,如果用jsp则可以做成动态的形式。
准备图片:
6TP0TINF4E9G0005[1].jpg
65A0AB9531J70008[1].jpg
6TP4ICSU4E9G0005[1].jpg
left.cur
right.cur
新建html页面:Noname1.html
原代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <style> #div1{ cursor:url(left.cur); } #div2{ cursor:url(right.cur); } </style> <script type="text/javascript"> <!-- function chgBackup(obj,imgsrc){ var divobj = obj.parentNode; divobj.style.background = 'url(' + imgsrc + ')'; divobj.style.backgroundRepeat = 'no-repeat'; divobj.style.backgroundPosition = 'center'; } //--> </script> </head>
<body> <div style="background:url(6TP0TINF4E9G0005[1].jpg) center;background-repeat:no-repeat;width:900px;height:564px;border:solid red 1px"> <div id="div1" style="float:left;width:50%;height:100%;" οnclick="chgBackup(this,'65A0AB9531J70008[1].jpg')"> </div> <div id="div2" style="float:left;width:49%;height:100%;" οnclick="chgBackup(this,'6TP4ICSU4E9G0005[1].jpg')"> </div> </div> <hr> </body></html>
效果图:
当鼠标在左边时,它会向左,如果鼠标在右边时,它会向右。
源码下载地址:
http://download.csdn.net/source/3043926