SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot manoloweb's Avatar
    Join Date
    Aug 2003
    Location
    Mexico
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image Map Creator

    Hello Javascripters!

    I'm mostly a PHP coder, but I understand JS basic structure and syntax. But this time really have no Idea how to solve this...

    I'm making a Image Map creator using PHP Dynamic Image Creation functions together with Javascript.

    Till now I have some advance on this, but it is not good, because every time the user selects a coordinate the page must reload completely, because I'm usin PHP to catch the X and Y position on the image. (I'm using a input type=image).

    Is there a way to catch those values IN javascript?

    I want to find the X and Y coordinates WITHIN the image, not related to the window or viewport. Meaning that if I click on the top-left corner of the image I should have 1,1

    Any help is wellcome!

    ;-)

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > I want to find the X and Y coordinates WITHIN the image.

    in IE it's as simple as

    <img onclick="alert([event.offsetX, event.offsetY])">

    in mozilla a bit trickier: you have to find an absolute position of the element (offsetLeft / Top) and substract absoulte mouse coords (event.pageX / Y)

  3. #3
    SitePoint Zealot manoloweb's Avatar
    Join Date
    Aug 2003
    Location
    Mexico
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, that sound logical. I hate having to split solutions to fit different browsers, though. But what else can I do?

    Thank you Setereofrog!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •