offsetTop working in IE7 but not with IE6
Posted on 2007-03-31
I'm developing a web site, I'm using IE7 on my development computer and everything is working fine. I had to test with IE 6, and something is not right. Here is a summary of the issue.
I got an image displayed in a DIV and I got mouse events on the image. On mouse down and mousemove, I will draw items in an invisible div over the image (that works perfectly in both versions of IE), but the problem occurs on MouseUp. The MouseUp will trigger on my "drawing form" (and not my image). I told myself, no worry since the image and the drawing canvas is the same size, I use the clientX and clientY with some calculation using the offsetLeft and offsetTop to get the coordinate relative to my image. This work fine with IE7. But in IE6 the offsetTop isn't giving the right information!
The IE7 will give me the correct offset of my image and his parent. But in IE6, there is 69 pixels more when looking at the offset of the parent. That means the calculation is off of 69pixels!
My question is the following: is there any way to get the correct offsetTop from IE6 ? Or is there any properties I should be looking at to get that information?