Fix normalization of pageX and pageY event properties in IE (#1571). Thanks wizzud.

This commit is contained in:
Brandon Aaron 2007-10-06 21:00:37 +00:00
parent 92aac3abd6
commit a5f95c88c1

View File

@ -267,8 +267,8 @@ jQuery.event = {
// Calculate pageX/Y if missing and clientX/Y available
if ( event.pageX == null && event.clientX != null ) {
var doc = document.documentElement, body = document.body;
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0);
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientLeft || 0);
}
// Add which for key events