Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > mouse cursor position

Reply
Thread Tools

mouse cursor position

 
 
DU
Guest
Posts: n/a
 
      11-13-2004
Michael Winter wrote:

> On Fri, 12 Nov 2004 16:01:08 -0500, DU <(E-Mail Removed)> wrote:
>
> [snip]
>
>> http://www10.brinkster.com/doctorunc...a7EventXY.html
>>

>
>
> From my reading of the reference, I see no bug:
>
> "This property returns the y-coordinate of the closest relatively
> positioned parent element of the element that fires the event. If
> the event firing element is relatively positioned, then the
> y-coordinate from the boundary of the element is returned."
>
> As both images are relatively positioned, the offset should be with
> regard to their borders.
>


The offset is relative to their borders but when you mouse over these,
the returned evt.x and evt.y in Opera 7.x are wrong.

Regarding the OP post, the x, y-coordinates are relative to relatively
positioned elements: if the page has relatively positioned elements,
then the returned values won't be relative to client viewport. That is
where your code is wrong.


> [snip]
>
> [MW:]
>
>>> var divX = evt.x || evt.clientX,
>>> divY = evt.y || evt.clientY;

>>
>>
>> The above does not make sense.

>
>
> It makes sense, but it's unnecessary. I didn't check whether IE
> supported clientX/Y, and I just assumed it didn't. My bad.
>


The above is wrong when the page will have relatively positioned
elements. When the mouse will hover over those relatively positioned
elements, the coordinates will not return browser window viewport
coordinates but coordinates relative to those relatively positioned
elements. As you say, just clientX/Y is sufficient.

DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.3
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to tell if cursor is sqlite.Cursor or psycopg2.Cursor dmaziuk Python 3 01-25-2011 04:52 AM
determine the mouse cursor position without mouse event tom arnall Java 6 01-18-2007 07:27 PM
Mouse Cursor Stops Moving... Mouse becomes invisible squall14414@gmail.com Computer Support 4 06-01-2006 10:52 PM
Set the cursor position to previous mouse click Jean-Benoit MORLA Java 1 05-24-2004 09:14 AM
OT: Position Mouse Cursor in centre of screen Slarty Bartfast MCSE 11 10-08-2003 06:49 PM



Advertisments