a question about get element's offsetLeft in Javascript

UNCONFIRMED
Unassigned

Status

()

Core
DOM
UNCONFIRMED
11 years ago
11 years ago

People

(Reporter: JimZheng, Unassigned)

Tracking

1.8 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1) Gecko/20061010 Firefox/2.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1) Gecko/20061010 Firefox/2.0

I have a question about get element's offsetLeft in Javascript.

My code like here:

var offsetLeft = el.offsetLeft;
while( el=el.offsetParent ){
offsetLeft += el.offsetLeft;
}

Those codes work correctly in IE, but it is not correct in FireFox. I searched about this question in Google, I think this is maybe a bug in firefox, isn't it? Can you help me how to get a element's offsetLeft in FireFox? I will appreciate your help in advance.

Thank you very much!


Sincerely

Jim Zheng

my email: lczheng@gmail.com

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Actual Results:  
alway return offsetLeft=0

Expected Results:  
actual element's offsetLeft

Comment 1

11 years ago
What do you mean by "doesn't work correctly"? Can you attach a minimized testcase showing exactly what the problem is?
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → 1.8 Branch
You need to log in before you can comment on or make changes to this bug.