dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: How get coordinates from every corner of "area"

  1. #1
    Join Date
    Feb 2007
    Posts
    1

    How get coordinates from every corner of "area"

    Hi.

    I would like to draw rectangle / square into web page and I would like to get
    coordinates of every corner. (I'm intrested to get information where this rectangle locates on page). Is this possible ?

    I know that I can get X/Y-coordinate when I click mouse, but this wont suit for me, because I would like to get coordinates-of area (example every corner coordinates)

    example:

    Code:
    -----------------------------------------------------
    |  web-page                                          |
    |                                                    |
    |   (x.y)  |-----------------------| (x.y)           |
    |          |                       |                 |
    |          |     area              |                 |
    |   (x.y)  |_______________________| (x.y)           |
    |                                                    |
    |-----------------------------------------------------

    How / what technique I have to use that I can make this happend ?
    Maybe drawing rectange is not the best solution ?
    Last edited by ManWithNoName; 02-13-2007 at 07:06 AM.

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Separate your aim.

    1. You want to draw a rectangle? Do you know how to do that?
    2. You want to get the coordinated of that rectangle?

  3. #3
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,203
    I assume when you say draw you mean use a div

    Maybe something on these lines

    areaEL=document.getElementById("area")

    topLeftX=areaEL.offsetLeft
    topLeftY=areaEL.offsetTop

    topRightX=areaEL.offsetLeft+areaEL.offsetWidth
    topRightY=areaEL.offsetTop

    bottomLeftX=areaEL.offsetLeft
    bottomLeftY=areaEL.offsetTop+areaEL.offsetHeight

    bottomRightX=areaEL.offsetLeft+areaEL.offsetWidth
    bottomRightY=areaEL.offsetTop+areaEL.offsetHeight

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles