0
<html>

<head>
<title>Question</title>
<script type="text/javascript" >
function MouseOverHand(ID)
{
  var Cursor='hand';
  var ID=ID;
  if (!document.all){ Cursor='pointer'; }
  document.getElementById(ID).style.cursor=Cursor;      
}
</script>
<script type="text/javascript" >
function MouseOverHelp(ID)
{
  var Cursor='help';
  var ID=ID;
  if (!document.all){ Cursor='pointer'; }
  document.getElementById(ID).style.cursor=Cursor;      
}
</script>
</head>

<body>
<label id="Hand" onmouseover="MouseOverHand('Hand');" > Hand </label><br/><br/>
<label id="Help" onmouseover="MouseOverHelp('Help');" > Help </label>
</body>

</html>

上面的 html 用于将鼠标光标置于标签的鼠标上方。在这里,“手”和“帮助”光标在 Internet Explorer 中工作正常,但在 Firefox 和其他浏览器中不工作。

4

3 回答 3

1

更简单的版本,适用于“所有”浏览器:

<script type="text/javascript" >
function MouseOverPointer(obj) //obj is the triggering element
{
    if(obj.id=='Help')
        obj.style.cursor = "help";
    else if(obj.id=='Hand')
        obj.style.cursor = "pointer";
}
</script>

<label id="Hand" onmouseover="MouseOverPointer(this);" > Hand </label><br/><br/>
<label id="Help" onmouseover="MouseOverPointer(this);" > Help </label>
于 2009-11-08T08:02:20.440 回答
1

var Cursor如果您可以指定helphand直接喜欢,则不需要

document.getElementById(ID).style.cursor='hand';        

document.getElementById(ID).style.cursor='help';        

请检查工作示例并查看 html 源代码

于 2009-11-08T08:02:39.267 回答
1

“手”在 Firefox 中不起作用。试试“指针”。然而,“帮助”应该可以工作——尝试以比通过 JS 更直接的方式应用样式。

于 2009-11-08T08:05:49.310 回答