Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#445 closed enhancement (fixed)

normalise pageX/pageY

Reported by: sam Owned by:
Priority: major Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:


As Internet Explorer does not support pageX and pageY it would be useful if the properties could still be used. The workaround I use at the moment is:

	event.pageX = event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft);
	event.pageY = event.clientY + (document.documentElement.scrollTop || document.body.scrollTop);

Works with no problems in IE7, Firefox 2 and Opera 8.5.

Change History (7)

comment:1 Changed 16 years ago by joern

Is there any browser apart from IE that doesn't provide pageX natively?

I'd rewrite the code a little:

if(!event.pageX) {
  var e = document.documentElement, b = document.body;
  event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
  event.pageY = event.clientY + (e.scrollTop || b.scrollTop);

comment:2 Changed 16 years ago by anonymous

This would be very helpful indeed

comment:3 Changed 16 years ago by Geoffreyk

If I had a dollar for everytime I have written this function.... I think this should be added to 1.1

comment:4 Changed 16 years ago by andrea ercol


comment:5 Changed 16 years ago by [email protected]

Very nice! I'm definitely for it.

comment:6 Changed 16 years ago by Alex Cook

Yes please :)

comment:7 Changed 16 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN.

Note: See TracTickets for help on using tickets.