Location.hash : Location « Location « JavaScript Tutorial

Home
JavaScript Tutorial
1.Language Basics
2.Operators
3.Statement
4.Development
5.Number Data Type
6.String
7.Function
8.Global
9.Math
10.Form
11.Array
12.Date
13.Dialogs
14.Document
15.Event
16.Location
17.Navigator
18.Screen
19.Window
20.History
21.HTML Tags
22.Style
23.DOM Node
24.Drag Drop
25.Object Oriented
26.Regular Expressions
27.XML
28.GUI Components
29.Dojo toolkit
30.jQuery
31.Animation
32.MS JScript
JavaScript Tutorial » Location » Location 




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














16.1.Location
16.1.1.Location
16.1.2.Location.assign()
16.1.3.Location.hash
16.1.4.Location.host
16.1.5.Location.hostname
16.1.6.Location.href
16.1.7.Location.pathname
16.1.8.Location.port
16.1.9.Location.protocol
16.1.10.Location.reload() to reload from cache
16.1.11.Location.reload(true) to reload from the server
16.1.12.Location.reload(false) to reload from the cache
16.1.13.Location.replace()
16.1.14.Location.search
16.1.15.Location replace in action
16.1.16.Change location.href
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.