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 Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.