$(document.documentElement).bind("mouseover", function(eventObj){
alert([eventObj.clientX, eventObj.clientY]);
});
On Thu, Feb 26, 2009 at 2:49 PM, d3r1v3d (Gavin Mulligan) <[email protected]
> wrote:
>
> Hi Marcus,
>
> The function I've always used for obtaining the current mouse position
> is:
> function getMousePosition(eventObj){
> if (eventObj.pageX && eventObj.pageY)
> {
> return {x: eventObj.pageX, y: eventObj.pageY};
> }
>
> return {x: (eventObj.clientX + document.body.scrollLeft -
> document.body.clientLeft),
> y: (eventObj.clientY + document.body.scrollTop -
> document.body.clientTop)};
> }
>
> However, the major caveat here is that you need to bind this function
> to some event. A given browser will keep track of mouse movements
> within itself, but I do not believe it tracks movements outside its
> window. Additionally, unless a user has moved their mouse within a
> given web page, I don't believe the DOM for that page is updated with
> the appropriate coordinates. So, long story short, I don't think what
> you're asking is possible.
>
> - Gavin
>
> On Feb 26, 9:41 am, smurkas <[email protected]> wrote:
> > Hello. I ran into this problem today. I would like to know the mouse
> > position when the page has loaded without the user having to move
> > the mouse. I have tried just getting the xy-values but it returned
> > undefined if I triggered on document load and 0 0 if I just trigger
> > different mouse events when the page has loaded via firebug.
> >
> > Is it possible to get the values without moving the mouse and if so,
> > how do I do it?
> >
> > Yours kindly, Marcus.
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---