Skip to main content

Bug Tracker

Side navigation

#1834 closed bug (wontfix)

Opened October 22, 2007 11:30PM UTC

Closed December 07, 2007 03:16AM UTC

event.clientX and clientY incorrect for Safari2

Reported by: jeffkretz Owned by:
Priority: major Milestone: 1.2.2
Component: event Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:

This is factually a bug/incompatibility in Safari, but the event normalization done in jQuery can address this issue.

For IE6, IE7, FF and Safari, on a click event, the clientX and clientY values are relative to the top left of the viewport. For Safari 2, they are relative to the top left of the document.

If you scroll down or to the right, the clientX and clientY for Safari is different from all the other browsers.

Sample page here:

One fix would be to add this right after the pageX/Y normalization script under the event.fix method:

// Fix clientX/Y for Safari.
if (jQuery.browser.safari) {
	var doc = document.documentElement, body = document.body;
	event.clientX = event.clientX - (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0);
	event.clientY = event.clientY - (doc && doc.scrollTop  || body && body.scrollTop  || 0) + (doc.clientLeft || 0);

This can be seen working on this page:


Attachments (0)
Change History (3)

Changed October 22, 2007 11:33PM UTC by jeffkretz comment:1


For IE6, IE7, FF and Opera, on a click event ...

Changed December 06, 2007 08:19PM UTC by joern comment:2

component: coreevent

Changed December 07, 2007 03:16AM UTC by brandon comment:3

resolution: → wontfix
status: newclosed

This is resolved in Safari 3