Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get size of mouse cursor in javascript

I need to determine the width and height of the current mouse cursor used on our webpage.

I need to show a div right under the cursor, and possibly to the right of it. So I need to determine the offsets of my div from the exact pointer location, so the cursor do not cover up the div.

The mechanism will be used in intranet system, so it can be firefox-only solution. Unfortunatelly some people here use weird cursors, anyway, big ones, so I cannot just hardcode eg, 16px right, 16px top offsets. Anyway, I don't want if I don't have to.

Thanks for your help.

like image 256
SWilk Avatar asked Dec 11 '09 17:12

SWilk


People also ask

How many pixels is a cursor?

Although the cursor size is also based on individual ope- rating systems and user preference, it usually ranges from 16x16 pixels to 32x32 pixels large.

What is cursor property in JavaScript?

The cursor indicates an alias of something is to be created. all-scroll. The cursor indicates that something can be scrolled in any direction. auto. Default.


1 Answers

You can't do it. Anyone can set their cursor to any arbitrary garbage, and there's no API for asking from the browser.

like image 195
Jonathan Feinberg Avatar answered Oct 06 '22 00:10

Jonathan Feinberg