JavaScript Reference/Javascript Properties/hash

Материал из Web эксперт
Перейти к: навигация, поиск

"hash" Example

    
<html>
<body>
<script language="JavaScript">
    function function1() {
        alert(document.getElementById("myLink").hash);
    }
</script>
<a tabindex="2" id="myLink" href="test.htm#sty" target="_blank">
    anchor element
</a>
<button onclick="function1();">Hash Value</button>
</body>
</html>



"hash" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <area>                        |
|                |location                                                      |
+----------------+--------------------------------------------------------------+



"hash" Syntax and Note

Note:
Read and write property.
Specifies the hash part of URL (the part that follows a # sign).
    
Syntax:
    
document.getElementById("elementID").hash = value
document.all.elementID.hash = value // IE only
location.hash = value