I connected the focus listener to the window (using the prototype syntax):
Event.observe( window, 'focus', focusCb.bindAsEventListener( this ) );
I want to determine the position of the mouse when focusing the window. Unfortunately, in my focusCb method I do not have access to pages, pages, client or client.
Using quirksmode code:
function doSomething(e) {
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
}
I always get 0, 0.
I thought the focal event would have mouse location information.
- Why does focus information not have this information?
- More importantly, how do I get the mouse position when focusing the window?
source
share