To get the current page URL, Use below code:
If you want to get hash value from current page URL, we just need to add .hash in the above javascript statement like: