From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.7) Gecko/20011221
For compatibility with Internet Explorer. The event property layerX should be
wrapped as Event.offsetX
I strongly disagree with any project to rename evt.layerX/Y properties as MSIE
5+'s event.offsetX/Y. These event properties are absolutely not the same.
In 1 sentence, their major difference is about whether the target element is
(absolutely or relatively) positioned or not, or if the target element is within
a (absolutely or relatively) positioned containing element.
MSIE event.offsetX/Y properties will store the X/Y mouse coordinate within the
target element (i.e. clicking inside an <img>), and this, regardless of
There is no built-in equivalent to MSIE's event.offsetX/Y in NS 6+. NS 6+
evt.layerX/Y properties are NOT the MSIE 5.x and 6 equivalent of event.offsetX/Y
properties. Under NS 6+, it is possible to calculate the offsetX/Y values.
Here's a way to get the equivalent of MSIE 5+ event.offsetX/Y properties:
var Element = evt.target ;
var CalculatedTotalOffsetLeft = CalculatedTotalOffsetTop = 0 ;
CalculatedTotalOffsetLeft += Element.offsetLeft ;
CalculatedTotalOffsetTop += Element.offsetTop ;
Element = Element.offsetParent ;
OffsetXForNS6 = evt.pageX - CalculatedTotalOffsetLeft ;
OffsetYForNS6 = evt.pageY - CalculatedTotalOffsetTop ;
NS 6+ evt.layerX/Y properties calculate the distance from the left/top corner of
an element if it is absolutely or relatively positioned; if it's not positioned,
then the values are the distance from the left/top of its closest absolutely or
relatively positioned containing element. In case the target element has no
positioned element within the containment hierarchy, then the body element is
the positioned containing element.
Here's an interactive demo on evt.layerX/Y :
: there are 2 exceptions to this: input type="text" and textarea elements.
When an event is fired, the evt.layerX/Y will return the X/Y mouse coordinate
within the input type="text" or within the textarea regardless of positioning
context. These 2 exceptions AFAIK are undocumented.
Wontfix then, since the two are different things. Thanks for the info!