使用JS实现在图片上显示左右箭头的翻页代码,预览效果网址:http://www.keleyi.com/keleyi/phtml/picnext/ 本实例使用了javascript的onmousemove 事件。onmousemove 事件会在鼠标指针移动时发生。 语法 onmousemove="SomeJavaScriptCode" SomeJavaScriptCode是必需参数。规定该事件发生时执行的 JavaScript。 下面是核心代码(完整代码请在效果页面查看源代码): 复制代码 代码如下: <BR>function KeleyiImgNext(bigimg) { <BR>var lefturl = "01.html"; <BR>var righturl ="03.html"; <BR>var imgurl = righturl; <BR>var width = bigimg.width; <BR>var height = bigimg.height; <BR>bigimg.onmousedown = bigimg.onmousemove = function () { <BR>if (event.offsetX < width / 2) { <BR>imgurl = lefturl; <BR>if (imgurl != "#") <BR>bigimg.style.cursor = 'url(images/arr_left.cur),auto'; <BR>else <BR>bigimg.style.cursor = 'default'; <BR>} else { <BR>imgurl = righturl; <BR>if (imgurl != '#') <BR>bigimg.style.cursor = 'url(images/arr_right.cur),auto'; <BR>else <BR>bigimg.style.cursor = 'default'; <BR>} <BR>} <BR>bigimg.onmouseup = function () { <BR>if (imgurl != '#') <BR>top.location = imgurl; <BR>} <BR>} <BR>