Location.hash : Location : Location JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Location » 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.navioo.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.navioo.com
    <br><br>
    <input type="button" name="getLoc" value="Get hash value" onClick='show()'>
    <br>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Location
» Location