Click to See Complete Forum and Search --> : How to determine x,y of and Anchor


jtwiii
06-05-2003, 08:56 PM
Hi, I have to migrate a menu function cuurently working fine in NS 4.x to IE. What I am looking for is how to determine the x,y coordinate of an HTML anchor, I've combed JScript reverences to no avail. I use the following for NS:

document.mylayer.visibility = "visible"
// anchorName is is filled by backend
// script builder...
xname = "document.anchors."+anchorName+".x"
yname = "document.anchors."+anchorName+".y"
eval("x = " + xname)
eval("y = " + yname)
document.mylayer.moveTo(x+20, y-7)

I'd appreciate any info on how to accomplish the same for IE...

Thanks in advance and best regards,
Jim W.

Khalid Ali
06-05-2003, 09:09 PM
In the generation 6+ browsers
object.offsetLeft and obj.offsetTop will give you the required info

jtwiii
06-10-2003, 08:32 AM
Thanks Dave, Khalid Ali for responding. I had investigated the offsetLeft and offsetTop and wondered why 1 was always returned.

Dave thanks for the link... the loop on the offset.parent to get the true offset worked.

Dave, FYI, I inherited the initial code and just wrote the back-end script processor around it a few years ago. Now that I have to mess with it I will definately incorporate your suggestion...

:D

Best regards,
Jim W

Self proclaimed halffast web programmer... :cool:


Sorry guys I would have responded sooner, for some reason I couldn't get through the FW until today...