What is the easiest way to parse an anchor from the current location of the page?

I need an anchor from window.location in JavaScript, for example, the following url:

 http://www.example.com/page.html#anchor1 

What is the easiest way?

+4
source share
2 answers

This should be exactly what you want:

 window.location.hash 
+5
source

All Articles