JS 获取鼠标坐标
2013-08-25 19:21
369 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>JavaScript获取鼠标坐标</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> .tip { width:200px; border:2px solid #ddd; padding:8px; background:#f1f1f1; color:#666; } </style> <script type="text/javascript"> function mousePos(e){ var x,y; var e = e||window.event; return { x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft, y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop }; }; function test(e){ document.getElementById("mjs").innerHTML = mousePos(e).x+','+mousePos(e).y; }; </script> </head> <body> <div id="mjs" class="tip">源码爱好者</div> <div id="test" style="width:1000px;height:1000px;background:#ccc;" onmousemove="test(event)"></div> </body> </html>
相关文章推荐
- 原生js获取鼠标X、Y轴坐标
- JS 获取 鼠标 坐标
- js获取鼠标坐标位置兼容多个浏览器
- js实时获取鼠标所在坐标
- js获取鼠标坐标
- js获取鼠标点击位置坐标
- JS获取鼠标坐标
- Js获取适时获取鼠标坐标值并显示
- 原生js获取鼠标坐标方法全面讲解:clientX/Y,pageX/Y,offsetX/Y,layerX/Y,screenX/Y
- js 火狐 iE 通用获取鼠标坐标,获取元素坐标
- JS获取鼠标坐标并且根据鼠标位置不同弹出不同内容
- 原生js获取鼠标坐标方法全面讲解:clientX/Y,pageX/Y,offsetX/Y,layerX/Y,screenX/Y
- js获取鼠标坐标,设置div的高度、位置、内容等,及注意要点
- 通过JS 获取Mouse Position(鼠标坐标)的代码
- js与jquery中获取当前鼠标的x、y坐标位置的代码
- js获取鼠标坐标实例
- JS网页在线获取鼠标坐标值的方法
- JS获取网页大小和鼠标当前坐标
- JS获取鼠标坐标代码
- js实时获取鼠标所在坐标