Closed Bug 485652 Opened 15 years ago Closed 14 years ago

offsetX and offsetY don't work as they should

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
trivial

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: walter_apaza, Unassigned)

Details

(Whiteboard: [CLOSEME 2010-11-01])

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727)
Build Identifier: 3.0.7

I'm a web developer and since very long time I've had the same doubt, there's a function called findPosX/Y, that return the position of any element inside the page, ok, that sounds great, but doesn't work exactly well, for example, to prove this I make a div position absolute and this follow the cursor, ok, it works but when it's embedded in tables, the position change 1 pixel per every table embedded.
I tried IE7 and FireFox 3.0.7, and they both have the same mistake about offsetX/Y, except for Opera, which works properly.
This question is a mistake in both browsers.
I just want a solution, or an explanation about this. I don't know why this kind of things happen, just happen and we as developers only can continuw without an answer.
Oh and just one more thing, this question is not over the internet, I've been looking for it for a long long time.
Obviously the only solution I could give was:
if(parent.tagName.toUpperCase()=="TABLE")
{
_left=parent.offsetX+1;
}else{
_left=parent.offsetX;
}

I just want why offsetX works like this.
Thanks

Reproducible: Always

Steps to Reproduce:
1.offsetX
2.offsetY
3.ClientX, clientY
Actual Results:  
Well, offsetX/Y work like in IE7, except in Opera

Expected Results:  
the exactly position of an element

function getPos(obj)
{
	var _left=0;
	var _top=0;
	var _parent=obj;
	while(_parent)
	{
		if(_parent.tagName.toUpperCase()=="TABLE")
		{
			y+=p.offsetTop+1;
			x+=p.offsetLeft+1;
		}else{
			_left+=_parent.offsetLeft;
			_top+=_parent.offsetTop;
		}
		_parent=_parent.offsetParent;
	}
	return {left:_left, top:_top};
}
Please use the correct method discussed at:
http://ejohn.org/blog/getboundingclientrect-is-awesome
This is a mass search for bugs which are in the Firefox General component, are
UNCO, have not been changed for 500 days and have an unspecified version. 

Reporter, can you please update to Firefox 3.6.10 or later, create a fresh profile, http://support.mozilla.com/en-US/kb/managing+profiles, and test again. If you still see the issue, please update this bug. If the issue is gone, please set the status to RESOLVED > WORKSFORME.
Whiteboard: [CLOSEME 2010-11-01]
No reply from reporter, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.