Latest web development tutorials

Location hash property

Location Object Reference Location Object

Definition and Usage

hash property is a readable and writable string that is the anchor part of the URL (from the beginning of the part number #).

grammar

location.hash


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support hash property


Examples

Examples

Back to the main part of the URL. Suppose the current URL is http://www.w3cschool.cc/test.htm#PART2:

<script>

document.write(location.hash);

</script>

Examples of the above output:

#part2


Location Object Reference Location Object