<div class="htmlarea"> <textarea id="runcode77318"> <div id="div1" style="cursor:hand;position:absolute;width:500;height:190;overflow:hidden;border:1 solid red" onmouseover="clearTimeout(scrl);" onmousemove="getpos()" onmouseout="change(1);"><img src="http://www.jb51.net/upload/out500b.jpg" onload="change(1);" alt="JS实现全景图效果360度旋转_图象特效" ></div> <script> var scrl,direction="right"; var x,xold,xdiff, i=1; function change(start){ if(direction == "right"){ if(div1.scrollTop+190 < div1.scrollHeight){ div1.scrollTop += 190; } else{ div1.scrollTop = 0; } } else{ if(div1.scrollTop-190 > 0){ div1.scrollTop -= 190; } else{ div1.scrollTop = div1.scrollHeight; } } if(start) scrl = setTimeout("change(1)",100); else clearTimeout(scrl); } function getpos(){ x = event.clientX; xdiff = x - xold; xold = x; if(xdiff>0) direction = "right"; if(xdiff<0) direction = "left"; change(0); } </script> </textarea><br><input onclick="runEx('runcode77318')" type="button" value="运行代码"> <input onclick="doCopy('runcode77318')" type="button" value="复制代码"> <input onclick="doSave(runcode77318)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>