Yes, but that requires the 'mouseover' event to be executed; which, in
turn, requires that a user move their mouse over the page at least a
pixel for it to trigger.

I believe Marcus was asking if it was possible to retrieve a user's
current mouse position without moving the cursor at all.

- Gavin

On Feb 27, 4:17 am, Andrea Giammarchi <andrea.giammar...@gmail.com>
wrote:
> $(document.documentElement).bind("mouseover", function(eventObj){
>     alert([eventObj.clientX, eventObj.clientY]);
>
> });
>
> On Thu, Feb 26, 2009 at 2:49 PM, d3r1v3d (Gavin Mulligan) <vtga...@gmail.com
>
> > 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 <marcus.dalg...@gmail.com> 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 jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to