Bug Tracker

Ticket #1322 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: arrix Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.1.3 Component: event
Version: 1.1.2 Keywords:
Cc: Needs: Review

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

Attachments

Change History

Changed 2 years ago by brandon

  • status changed from new to closed
  • resolution set to fixed

Fixed in Rev [2193].

Note: See TracTickets for help on using tickets.