简体   繁体   English

在javascript中获取鼠标光标的大小

[英]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. 我需要在光标下面显示一个div,可能在它的右边。 So I need to determine the offsets of my div from the exact pointer location, so the cursor do not cover up the div. 所以我需要从精确的指针位置确定div的偏移量,因此光标不会掩盖div。

The mechanism will be used in intranet system, so it can be firefox-only solution. 该机制将用于Intranet系统,因此它可以是仅限firefox的解决方案。 Unfortunatelly some people here use weird cursors, anyway, big ones, so I cannot just hardcode eg, 16px right, 16px top offsets. 不幸的是,这里的一些人使用奇怪的游标,无论如何,大的,所以我不能只硬编码,例如16px右,16px顶部偏移。 Anyway, I don't want if I don't have to. 无论如何,如果我不需要,我不想要。

Thanks for your help, SWilk 谢谢你的帮助,SWilk

You can't do it. 你不能这样做。 Anyone can set their cursor to any arbitrary garbage, and there's no API for asking from the browser. 任何人都可以将光标设置为任意垃圾,并且没有用于从浏览器询问的API。

I don't think this it is possible to determine any more than the cursor center within the browser. 我不认为可以确定浏览器中的光标中心以外的任何内容。 It surely can be done using a custom-made Firefox extension but I doubt there are any around for this specific task. 它肯定可以使用定制的Firefox扩展来完成,但我怀疑这个特定的任务有什么。

While size is not possible, there are jQuery addons like SimpleTip and qTip that let you create fixed-position tool tips that don't close until something happens (like the user clicks on it). 虽然大小是不可能的,但有一些jQuery插件,如SimpleTipqTip ,可以让你创建固定位置的工具提示,这些技巧在发生某些事情之前不会关闭(比如用户点击它)。 The content of the tool tips can be wrapped in divs. 工具提示的内容可以用div包装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM