Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > onclick image coordinates from Konqueror and Safari

Reply
Thread Tools

onclick image coordinates from Konqueror and Safari

 
 
Roger
Guest
Posts: n/a
 
      09-26-2005
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
 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      09-26-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
One bug to rule them all - IE, Firefox, Safari, Opera, Konqueror,Seamonkey, Wii, PS3, iPhone, iPod, Nokia, Siemens, Ubuntu.... and more. Max Burke NZ Computing 1 07-16-2009 08:47 AM
Javascript Oddness in Safari / Konqueror lasmit Javascript 0 10-31-2006 01:10 PM
Konqueror/Safari problem: DHTML-generated links and frames gubusoft@gubusoft.com Javascript 1 09-26-2006 09:04 PM
Konqueror Quirk? Safari? Blinky the Shark HTML 9 02-20-2004 06:17 AM
CSS3 opacity support in Konqueror 3.1+ and Safari 1.1 DU HTML 13 10-31-2003 12:51 AM



Advertisments