光标在Firefox Mac上消失并且没有重置

Cursor disappears on Firefox Mac and doesn't reset

本文关键字:消失 Firefox Mac 光标      更新时间:2023-09-26

我正在开发一个网页,我需要隐藏光标在一个特定的区域(div)和显示自定义光标在另一个区域。它在所有浏览器上都能很好地工作,但只有在Firefox Mac上,光标隐藏起来,再也不会回来。我已经拿出了这段代码,这是导致这个问题(JSFiddle链接)。

$( "#left" ).mousemove(function( event ) {
    leftDiv.style.cursor = "none";
    console.log("Left - " + leftDiv.style.cursor);
});
$( "#right" ).mousemove(function( event ) {
    rightDiv.style.cursor = "url('http://cur.cursors-4u.net/cursors/images11/cur1047.png'), auto";
    console.log("Right - " + rightDiv.style.cursor);
});

下面是如何复制的尝试在空白区域和文本区域之间连续移动光标,在某些时候光标完全消失,根本看不见。这可以通过一些工作来解决吗?我在这里看到firefox的一个bug

不使用"none"属性来隐藏光标,如果我们使用一个带有"auto"属性的URL,它就可以工作了。

$( "#left" ).mousemove(function( event ) {
leftDiv.style.cursor = "url('http://www.jholjhaal.com/wp-content/uploads/2013/05/HiddenCursor.cur'), auto";
console.log("Left - " + leftDiv.style.cursor);
});
$( "#right" ).mousemove(function( event ) {
rightDiv.style.cursor = "url('http://cur.cursors-4u.net/cursors/images11/cur1047.png'), auto";
console.log("Right - " + rightDiv.style.cursor);
});

这种方法的问题是,如果url中指定的资源不存在,那么浏览器的默认光标将显示而不是隐藏。