Skip to content

Instantly share code, notes, and snippets.

@dshaw
Created September 14, 2010 17:35
Show Gist options
  • Select an option

  • Save dshaw/579438 to your computer and use it in GitHub Desktop.

Select an option

Save dshaw/579438 to your computer and use it in GitHub Desktop.
// From jQuery source
// 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) - (doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment