469,272 Members | 1,482 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Get relative coords of clicked image

I have a image in a scrollable DIV. The image is bigger than the display
size of the DIV. How do I get the coordinates of a mouse click on the
image relative to the top left corner of the image itself?

Andrew Poulos
Aug 6 '08 #1
1 1129
Andrew Poulos wrote:
I have a image in a scrollable DIV. The image is bigger than the display
size of the DIV. How do I get the coordinates of a mouse click on the
image relative to the top left corner of the image itself?
Handle the `click' event of the `img' element and subtract the image's
coordinates that are relative to the viewport's top left corner from the
pointer coordinates that are relative to the viewport's top left corner.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Aug 6 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Stephen Weatherly | last post: by
2 posts views Thread by Stimp | last post: by
20 posts views Thread by Geoffrey H. Goldberg | last post: by
2 posts views Thread by Robin Senior | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.