Location hashProperty
Definition and Usage
The hash property is a readable and writable string that is the anchor part of the URL (the part starting with the # sign).
Syntax
location.hash
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the hash property.
Example
Example
Return the main part of a URL. Suppose the current URL is http://www.example.com/test.htm#PART2:
document.write(location.hash);
The output of the above example is:
#part2
Other Extensions
Location Object