Bug Tracker

Modify

Ticket #445 (closed enhancement: fixed)

Opened 6 years ago

Last modified 6 years ago

normalise pageX/pageY

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

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

comment:1 Changed 6 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 6 years ago by anonymous

This would be very helpful indeed

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

good

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

Very nice! I'm definitely for it.

comment:6 Changed 6 years ago by Alex Cook

Yes please :)

comment:7 Changed 6 years ago by joern

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in SVN.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.