Chrome 强制默认鼠标光标?
我正在尝试使用 JS/CSS 以编程方式更改鼠标光标,这是我的问题:Chrome 似乎会*强制将指针返回到默认指针,无论将其设置为什么。
下面是一个说明问题的最小示例:
<html>
<head>
<style type="text/css">
div#mouse_test
{
cursor: crosshair;
}
</style>
<body>
<div id="mouse_test">Here is a small div</div>
</body>
</html>
当我在 Firefox 中查看上面的示例时,它按预期工作,因为将鼠标悬停在 div 的文本上会将光标更改为十字准线。
但是,当我在 Chrome 中查看它时,光标变为十字准线,然后(大约一秒钟后)变回默认指针。
有人有任何见解吗? Chrome 确实强制使用默认指针吗?如果是这样,有什么办法可以解决这个问题吗?
任何帮助将不胜感激。谢谢!
已修复 事实
证明,重新启动浏览器解决了该问题。不过,仍然很奇怪,因为我在*每个更改鼠标光标的页面(我正在处理的页面)以及我正在查看的带有 CSS 光标示例的几个页面上看到了问题行为。我使用 JS 计时器来设置光标,因此其中一个计时器可能在后台徘徊。仍然很奇怪,因为多个选项卡的行为完全一致。
非常感谢 Stack Overflow 社区快速而有用的回复:)
I'm attempting to change the mouse cursor programmatically using JS/CSS, and here's my problem: it seems that Chrome will *force the pointer back to the default pointer no matter what one sets it to.
Here's a minimal example that illustrates the problem:
<html>
<head>
<style type="text/css">
div#mouse_test
{
cursor: crosshair;
}
</style>
<body>
<div id="mouse_test">Here is a small div</div>
</body>
</html>
When I view the above example in Firefox, it works as expected, in that mousing over the text of the div changes the cursor to a crosshair.
When I view it in Chrome, though, the cursor changes to a crosshair then (after about a second) changes back to the default pointer.
Does anyone have any insights? Is it true that Chrome forces the default pointer? If so, is there any way to get around that?
Any help would be greatly appreciated. Thanks!
FIXED
Turns out that restarting my browser fixed the issue. Still odd, though, as I was seeing the problem behavior on *every page that changed the mouse cursor- the one I was working on, as well as several pages with CSS cursor examples that I was viewing. I was working with JS timers to set the cursor, so it's possible that one of those was hanging around in the background. Still odd, since the behavior was completely consistent across multiple tabs.
Big thanks to the Stack Overflow community for the quick and helpful responses :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Chrome 9 中不会发生这种情况。
所以我不相信它会强制指针。
重新启动浏览器并重试(有时我的光标在指针和正常之间闪烁)。
That doesn't happen for me in Chrome 9.
So I don't believe it forces the pointer.
Restart your browser and try again (sometimes my cursor flickers between the pointer and normal).