2016-09-26 84 views
1

我正在開發一個網頁,我需要將光標隱藏在特定區域(div)中並在其他區域中顯示自定義光標。 它適用於所有瀏覽器,但只在Firefox Mac上,光標隱藏並永不再回來。我已經拿出了導致這個問題的一段代碼(JSFiddle Link)。光標在Firefox Mac上消失並且不會重置

$("#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上報告的錯誤here

回答

0

而不是使用「none」屬性來隱藏遊標,如果我們使用一個帶有後備的URL作爲「auto」,它就起作用了。

$("#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指定的資源不存在,那麼瀏覽器的默認光標會出現,而不是隱藏的。