Search w3schools.com:

SHARE THIS PAGE

Location hash Property

Location Object Reference Location Object

Definition and Usage

The hash property returns the anchor portion of a URL, including the hash sign (#).

Syntax

location.hash


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The hash property is supported in all major browsers.


Example

Example

Return the anchor portion of a URL. Assume that the current URL is http://www.example.com/test.htm#part2:

<script>

document.write(location.hash);

</script>

The output of the code above will be:

#part2


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]