Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object position wont work with netscape, need help! 1

Status
Not open for further replies.

fredes65

Programmer
Mar 2, 2002
9
AU
I have this neet code that I got from some helpful people on the list which gets the absolute position of a relatively positioned object including its parent objects.
The problem is that it works great on ie but not at all in Netscape. Anyone know why? Please help!!
heres the code:

function showmenu(elemName) {


if (document.getElementById) {

t = elemName.offsetTop;
l = elemName.offsetLeft;
tempelem = elemName;
while (tempelem.parentNode != null) {
tempelem = tempelem.parentNode;
t = t + tempelem.offsetTop;
l = l + tempelem.offsetLeft;
}
}

 
Here's the basic syntax for getting the position:

IE: document.all.myDiv.offsetLeft / offsetTop
NS4: document.layers.myDiv.pageX / pageY
NS6: document.getElementById("myDiv").offsetLeft / offsetTop
bluebrain.gif
blueuniment.gif
 
thanks,

the way my code works with ns6 does not produce the same results as IE. the positions found are way off scale!

could you explain why this is so?

cheers
fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top