onclick image coordinates from Konqueror and Safari

Discussion in 'Javascript' started by Roger, Sep 26, 2005.

  1. Roger

    Roger Guest

    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
     
    Roger, Sep 26, 2005
    #1
    1. Advertising

  2. Roger

    RobG Guest

    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
     
    RobG, Sep 26, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DU
    Replies:
    13
    Views:
    947
  2. Blinky the Shark

    Konqueror Quirk? Safari?

    Blinky the Shark, Feb 18, 2004, in forum: HTML
    Replies:
    9
    Views:
    451
    Blinky the Shark
    Feb 20, 2004
  3. Suresh  Kumar
    Replies:
    0
    Views:
    596
    Suresh Kumar
    Jul 3, 2003
  4. Replies:
    1
    Views:
    123
  5. lasmit
    Replies:
    0
    Views:
    112
    lasmit
    Oct 31, 2006
Loading...

Share This Page