aximbigfan Posted May 16, 2008 Share Posted May 16, 2008 I need to know 2 things, 1. Is there a bit of code to something like this: var mouse = <mouse cord for X axis> 2. Can I figure out at what position (X axis) of an element, like a table? like this: "var offset = <start pos of element on the X axis> Thanks! Chris Link to comment https://forums.phpfreaks.com/topic/105996-mouse-location-element-location/ Share on other sites More sharing options...
mainewoods Posted May 20, 2008 Share Posted May 20, 2008 --for the position of an element on a web page, i use it and it works great http://www.quirksmode.org/js/findpos.html Link to comment https://forums.phpfreaks.com/topic/105996-mouse-location-element-location/#findComment-545351 Share on other sites More sharing options...
The Little Guy Posted May 20, 2008 Share Posted May 20, 2008 I do something like this: function mouseLocation(e) { var posx = 0; var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } // posx and posy contain the mouse position relative to the document // Do something with this information alert(posx +' '+posy); } <a href="javascript:void(0);" onclick="javascript:mouseLocation(event);">click me</a> Link to comment https://forums.phpfreaks.com/topic/105996-mouse-location-element-location/#findComment-545457 Share on other sites More sharing options...
aximbigfan Posted May 20, 2008 Author Share Posted May 20, 2008 Thanks Little Guy! I shall try that too! Chris Link to comment https://forums.phpfreaks.com/topic/105996-mouse-location-element-location/#findComment-545461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.