Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 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:

Description

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:

if(!event.pageX)
{
	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 13 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 13 years ago by anonymous

This would be very helpful indeed

comment:3 Changed 13 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 13 years ago by andrea ercol

good

comment:5 Changed 13 years ago by paul.bakaus@…

Very nice! I'm definitely for it.

comment:6 Changed 13 years ago by Alex Cook

Yes please :)

comment:7 Changed 13 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN.

Note: See TracTickets for help on using tickets.