469,903 Members | 2,031 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

onclick image coordinates from Konqueror and Safari

I am trying to capture the image coordinates when a user clicks on an
image. My code is working in Firefox, Mozilla, Netscape, IE, and
Opera, but fails under Konqueror (and I suspect Safari). The code below
fails in Konqueror when the page is scrolled down; the coordinates are
off by the scroll amount.

My code in the html img tag: onClick="MLDot(event)"

and the related statements in the MLDot function:

xPosition =
event.offsetX?(event.offsetX):event.pageX-document.getElementById("clickImage").offsetLeft;
yPosition =
event.offsetY?(event.offsetY):event.pageY-document.getElementById("clickImage").offsetTop;

Anyone know how to pick up image coordinates in Konqueror/Safari?

TIA,
Roger
Sep 26 '05 #1
1 4305
Roger wrote:
I am trying to capture the image coordinates when a user clicks on an
image. My code is working in Firefox, Mozilla, Netscape, IE, and
Opera, but fails under Konqueror (and I suspect Safari). The code below
fails in Konqueror when the page is scrolled down; the coordinates are
off by the scroll amount.

My code in the html img tag: onClick="MLDot(event)"

and the related statements in the MLDot function:

xPosition =
event.offsetX?(event.offsetX):event.pageX-document.getElementById("clickImage").offsetLeft;

yPosition =
event.offsetY?(event.offsetY):event.pageY-document.getElementById("clickImage").offsetTop;
Anyone know how to pick up image coordinates in Konqueror/Safari?


I can't test in Safari right now, but finding the position of an element
in a page is not simple. The following link should help:

<URL:http://www.quirksmode.org/js/findpos.html>

Essentially you have to climb up the offsetParent tree (which may be
different to the DOM tree) to get the real position of the element.
--
Rob
Sep 26 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jonne | last post: by
3 posts views Thread by esingley | last post: by
3 posts views Thread by Greg Heilers | last post: by
9 posts views Thread by Maxi | last post: by
3 posts views Thread by jackiepatti | last post: by
6 posts views Thread by jesper_lofgren | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.