September 17, 2004 8:35 AM Subscribe
posted by weston to computers & internet (3 answers total)
For a click on a given element, I want to be able capture the x/y coordinates of the mouse -- not relative to the top of the document, but rather, relative to the top left corner of the clicked-on element.
So far, here's what I've got:
It seems to work in Gecko-based browsers, and IE/Win.
It seems to break badly in Safari, grabbing what is apparently instead the viewport position of the mouse. Also, on IE/Mac, it breaks if there's any scrolling done on the page (try resizing the window so that it's smaller than the sample image, then scrolling down, and then clicking).
Any ideas what I can do to make it work better for the Mac browsers? Also, any other platforms which you observe it breaking under?