onclick image coordinates from Konqueror and Safari

R

Roger

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
 
R

RobG

Roger said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top