Mega Code Archive

 
Categories / JavaScript Tutorial / Location
 

Location hash

The hash property refers to the anchor portion of the URL, including the hash symbol (#). If the URL contains a pound sign (#), this returns the content after it (for example, http://www.rntsoft.com/index#section1 has a hash equal to "#section1"). <html>     <head>     <title> Using the hash property of the Location object</title>     </head>     <body>     <script language="JavaScript">     <!--     function show(){           alert(document.location.hash);     }     -->     </script>     <form name="form1">     Click the button to get the current location.hash     value of the following address:     <br>     http://www.rntsoft.com     <br><br>     <input type="button" name="getLoc" value="Get hash value" onClick='show()'>     <br>     </form>     </body>     </html>