效果图
代码,<img src='{label:index_pc}'是图片地址,插入index模板即可生效
<div id="imglayer" style="position:absolute;mergin:0px; padding:0px;left:0px;top:0px;Z-INDEX:999999;visibility:hidden;"> <script language="JavaScript">document.write("<a><img src='{label:index_pc}' border=0 \/><\/a>");</script> </div> <SCRIPT LANGUAGE="JavaScript"> <!-- var xPos = 20; var yPos = document.documentElement.scrollTop; var step = 1; var delay = 30; var width=0; var height = 0; var Hoffset = 0; var Woffset = 0; var yon = 0; var xon = 0; var pause = true; var interval; var imgly=document.getElementById("imglayer"); imgly.style.top = yPos+"px"; function changePos() { var top = document.body.scrollTop; var left = document.body.scrollLeft; if(document.documentElement.scrollTop >= document.body.scrollTop){ top = document.documentElement.scrollTop; left = document.documentElement.scrollLeft; } width = document.body.clientWidth; height = document.documentElement.clientHeight; Hoffset = imgly.offsetHeight; Woffset = imgly.offsetWidth; // $("#imglayer").css("left",xPos + left); // $("#imglayer").css("top",yPos + top); imgly.style.left = (xPos + left) + "px"; imgly.style.top = (yPos + top) + "px"; yPos = yon ? yPos + step : yPos - step; if (yPos < 0) { yon = 1; yPos = 0; } if (yPos >= (height - Hoffset)) { yon = 0; yPos = (height - Hoffset);} xPos = xon ? xPos + step : xPos - step; if (xPos < 0) { xon = 1; xPos = 0;} if (xPos >= (width - Woffset)) { xon = 0; xPos = (width - Woffset);} } imgly.style.visibility = "visible"; interval = setInterval("changePos()", delay); $("#imglayer").mouseover(function(){ window.clearInterval(interval); }); $("#imglayer").mouseout(function(){ interval = setInterval("changePos()", delay); }); --> </script>