使用JS实现在图片上显示左右箭头的翻页代码,预览效果网址:http://www.keleyi.com/keleyi/phtml/picnext/ 本实例使用了javascript的onmousemove 事件。onmousemove 事件会在鼠标指针移动时发生。 语法 onmousemove="SomeJavaScriptCode" SomeJavaScriptCode是必需参数。规定该事件发生时执行的 JavaScript。 下面是核心代码(完整代码请在效果页面查看源代码): 复制代码 代码如下: <script type="text/javascript"> function KeleyiImgNext(bigimg) { var lefturl = "01.html"; var righturl ="03.html"; var imgurl = righturl; var width = bigimg.width; var height = bigimg.height; bigimg.onmousedown = bigimg.onmousemove = function () { if (event.offsetX < width / 2) { imgurl = lefturl; if (imgurl != "#") bigimg.style.cursor = 'url(images/arr_left.cur),auto'; else bigimg.style.cursor = 'default'; } else { imgurl = righturl; if (imgurl != '#') bigimg.style.cursor = 'url(images/arr_right.cur),auto'; else bigimg.style.cursor = 'default'; } } bigimg.onmouseup = function () { if (imgurl != '#') top.location = imgurl; } } </script> <img onmouseover="KeleyiImgNext(this)" src="http://www.keleyi.com/keleyi/phtml/picnext/images/k02.jpg" alt="keleyi" />
推荐阅读
jQuery编辑器KindEditor4.1.4代码高亮显示设置教程
编辑器KindEditor官网: http://www.kindsoft.net/ 1、需要加载的JS和CSS文件为: 复制代码 代码如下: <script src="kindeditor-4.1.4/kindeditor.js" type="text/javascript" charset="utf-8"></script> <script >>>详细阅读
本文标题:在图片上显示左右箭头类似翻页的代码
地址:http://www.17bianji.com/kaifa2/JS/22305.html
1/2 1