Bug Tracker

Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#7319 closed bug (patchwelcome)

IE: event.pageX and event.pageY not using scroll if element belongs to a different document

Reported by: bgrins Owned by:
Priority: low Milestone: 1.next
Component: event Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by Rick Waldron)

I ran into an issue in IE where the pageX and pageY were not being computed properly (that is, not consistent with native pageX/pageY calculations from other browsers).

Test Case: http://jsfiddle.net/nfyVy/

Inside event.js, this small change seems to fix it:

if (event.pageX == null && event.clientX != null) {
   var ownerDoc = event.target.ownerDocument || document;
   var doc = ownerDoc.documentElement, body = ownerDoc.body;

EXCEPT: When there is a frameborder on the frame, the ownerDocument has a clientLeft of 2, so everything is shifted by 2px (for example, if you are at the position (0, 0) the pageX/pageY are -2/-2. I'm not sure why it is using this clientLeft property anyway, can anyone explain?

Change History (3)

comment:1 Changed 9 years ago by Rick Waldron

Component: unfiledevent
Description: modified (diff)
Priority: undecidedlow
Status: newopen

comment:2 Changed 9 years ago by john

Milestone: 1.next

comment:3 Changed 8 years ago by dmethvin

Resolution: patchwelcome
Status: openclosed

I can see the issue you describe in IE8. In general, cross-iframe issues are often hard to solve in older versions of IE. Since this ticket has been open a while it's unlikely we'll get to it soon. If someone can propose a simple patch that fixes the problem, please let us know by posting a message on the "Developing jQuery core" section of forums.jquery.com.

Note: See TracTickets for help on using tickets.