/    Sign up×
Community /Pin to ProfileBookmark

x,y of image with onmousemove event

I have an image on my page. Just wondering if its possible to attach an onmousemove event that will display the x,y coordiantes of the image and how would I do that.
<img src=”assets/header.gif” width=”700″ height=”70″

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ricpMay 05.2007 — Ok,well you can pick up the x/y co-ords of the mouse pointer, that's easy enough with the .x / .y (for IE) and .pageX / .pageY (for Moz) properties on the event object.

However to find the specific x/y position of the element you would need to use a little extra code. Have a look at http://faq.ii.no/abspos which contains a simple function to return the co-ords of the top/left corner of your element.
×

Success!

Help @jonblaze87 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...