By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,814 Members | 2,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,814 IT Pros & Developers. It's quick & easy.

onclick image coordinates from Konqueror and Safari

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.