HTML DOM hash 属性

定义和用法

hash 属性可设置或返回一个区域中 URL 的锚部分。

语法

areaObject.hash=anchorname

实例

下面的例子可把 URL 的锚部分 #top 更改为 #bottom:

<html>
<head>
<script type="text/javascript">
function changeLink()
  {
  document.getElementById('venus').hash="bottom"
  }
</script>
</head>
<body>

<img src=/w3c/jsref/"planets.gif" __width="145" height="126" __usemap="#top" />
</map>

<input type="button" onclick="changeLink()" value="Change link" />

</body>
</html>