[Javascript] getting position

Chris T christ at saeweb.com
Tue Jun 22 10:03:28 CDT 2004


Here's some code I have on a current app:
-------------------


 function defineCropRegion(){
  var objItem = document.getElementById("editImage")
  var objParent = null
  var intX = 0
  var intY = 0
  do
   { // Walk up our document tree until we find the body
    // and add the distance from the parent to our counter.
    intX += objItem.offsetLeft
    intY += objItem.offsetTop
    objParent = objItem.offsetParent.tagName
    objItem = objItem.offsetParent
   }
  while(objParent != 'BODY')


  var myScrollX
  var myScrollY
  (isIE) ? myScrollX = document.body.scrollLeft: myScrollX =
window.pageXOffset;
  (isIE) ? myScrollY = document.body.scrollTop: myScrollY =
window.pageYOffset;

  var intImgLeft = intX - myScrollX
  var intImgTop = intY - myScrollY
 }


----- Original Message ----- 
From: "Iztok Polanic" <iztokp at amis.net>
To: <javascript at LaTech.edu>
Sent: Tuesday, June 22, 2004 10:34 AM
Subject: [Javascript] getting position


> Hi!
>
> I'm wondering how to get a position (x, Y) of an object by its ID. How to
do
> this?
>
>
> Bye,
>
> Iztok
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list