This worked for me:

var x;
var y;

Event.observe(document, 'mousemove', function(event){

x = Event.pointerX(event);
y = Event.pointerY(event);



Ian Tyndall wrote:
> From mailing list 7-21-06 By Thomas Fuchs:
> This works for me, but it's a bit ugly... :)
>
> Event.localPointer = function(event){
>   var p = [Event.pointerX(event), Event.pointerY(event)];
>   var element = arguments[1] || Event.element(event);
>   var e = Position.page($(element));
>   return [
>     p[0]-(e[0]+(window.pageXOffset ||
> document.documentElement.scrollLeft || document.body.scrollLeft || 0)),
>     p[1]-(e[1]+(window.pageYOffset ||
> document.documentElement.scrollTop  || document.body.scrollTop  || 0))];
> }
>
> >Hi,
> >
> >Question:
> >Is there a way to get the position (top / left or x / y coordinates) of
> >any element?
> >
> >Goal:
> >The goal is to have a product listing type page with a div that appears
> >onmouseover for each item. I was thinking it would be really nice if I
> >could have just one div at the end of the HTML, move it to where the
> >moused over object is, and fill it with the changing information as
> >needed.
> >
> >Tried:
> >I tried just getting the left and top styles from each element, but
> >they are null unless they have been explicitly set in my CSS, which
> >would defeat the purpose.
> >
> >I thought I would throw this question out there...If there is a way to
> >do this, awesome. If this functionality is possible, but not available
> >now, I think this would be a great addition to scriptaculous.
> >
> >Thanks in advance for any time and help you can offer,
> >Mike.
> >
> >>
> >
> >
> >  
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to