2010-09-22 124 views
2

在Firefox 3.6.10和3.6.7中,當第一次加載頁面並且鼠標指針位於鏈接上時,它變成了一隻手。但是,當我通過JavaScript將錨標記光標樣式設置爲auto時,並將鼠標指針懸停在同一個錨標記上時,它會顯示爲它是純文本。在IE8和Chrome中,它按預期工作(由我)。Firefox css光標屬性在錨標記

我理解錯了嗎?

<html lang="en"> 
<head> 
<script type="text/javascript"> 
function cursor_auto() { 
    document.getElementById('anchor').style.cursor = 'auto'; 
} 
function cursor_pointer() { 
    document.getElementById('anchor').style.cursor = 'pointer'; 
} 
</script> 
</head> 
<body> 
<a href="http://example.com" id="anchor">Example</a> 
<input type="button" onclick="cursor_auto();" value="Cursor Auto"> 
<input type="button" onclick="cursor_pointer();" value="Cursor Pointer"> 
</body> 
</html> 

回答

1

不要認爲這是你的代碼有問題 - 可能是FF錯誤。這也無法正常工作(不涉及js):

<a href="http://example.com" id="anchor" style="cursor:auto">Example</a> 

忘了解決方法。最好用一個按鈕添加一個類,並用另一個按鈕刪除它。這樣,您不會以混亂的內聯樣式結束,並且可以輕鬆地恢復爲默認值。

0

你想讓指針看起來像一個稍微向上傾斜的箭頭嗎?如果是的話,試試這個代碼:

<a href="http://example.com" id="anchor" style="cursor:default">Example</a> 

它的工作在Firefox中,當我試了一下,應該在其他瀏覽器,據我瞭解正常工作。儘管如此,以防萬一我錯了。

如果這不是您想要的,您可以在http://www.w3schools.com/CSS/pr_class_cursor.asp找到指針的更多屬性值。