Bug Tracker

Opened 15 years ago

Closed 15 years ago

#1834 closed bug (wontfix)

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:



Change History (3)

comment:1 Changed 15 years ago by jeffkretz


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

comment:2 Changed 15 years ago by joern

Component: coreevent

comment:3 Changed 15 years ago by brandon

Resolution: wontfix
Status: newclosed

This is resolved in Safari 3

Note: See TracTickets for help on using tickets.