Bug Tracker

Opened 14 years ago

Closed 14 years ago

#1322 closed bug (fixed)

event.pageX/Y fails with page scrolls in IE quirks mode

Reported by: arrix Owned by:
Priority: major Milestone: 1.1.3
Component: event Version: 1.1.2
Keywords: Cc:
Blocked by: Blocking:

Description

IE is notorious for its inconsistent rendering mode. In standard-compliant mode, document.documentElement.scrollLeft/Top tell the actual page scroll offsets. But in quirks mode, document.body.scrollLeft/Top tell the truth and document.documentElement.scrollLeft/Top is always 0. Tested with IE7 Windows Server 2003 R2 SP2.

A possible fix


Index: E:/zm/jquery/jquery/src/event/event.js
===================================================================
--- E:/zm/jquery/jquery/src/event/event.js	(revision 2158)
+++ E:/zm/jquery/jquery/src/event/event.js	(working copy)
@@ -226,9 +226,9 @@
 
 		// Calculate pageX/Y if missing and clientX/Y available
 		if ( event.pageX == null && event.clientX != null ) {
-			var e = document.documentElement || document.body;
-			event.pageX = event.clientX + e.scrollLeft;
-			event.pageY = event.clientY + e.scrollTop;
+			var e = document.documentElement, b = document.body;
+			event.pageX = event.clientX + (e && e.scrollLeft || b && b.scrollLeft);
+			event.pageY = event.clientY + (e && e.scrollTop || b && b.scrollTop);
 		}
 			
 		// Add which for key events

Change History (1)

comment:1 Changed 14 years ago by brandon

Resolution: fixed
Status: newclosed

Fixed in Rev [2193].

Note: See TracTickets for help on using tickets.