JavaScript Reference/Javascript Properties/hash

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

"hash" Example

   <source lang="javascript">
   

<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>


     </source>
   
  


"hash" is applied to

   <source lang="javascript">

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

     </source>
   
  


"hash" Syntax and Note

   <source lang="javascript">

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


     </source>