How to get everything to hash from address bar using Javascript?

I know that I can get the hash value directly with this bit of code:

var hash = window.location.hash; 

But anyway, can I get everything up to the hash value directly?

Thanks!

Edit using the answer below . I guess the best way is ...

 var pageAddress = window.location.split('#')[0]; 
+6
source share
4 answers

I use:

 window.location.href.replace(window.location.hash, ''); 
+15
source

you can try to subtract it from the location

+1
source

This took me 2s on Google: http://davidwalsh.name/javascript-window-location

You want to take href and split it into "#", it's easy enough to do in JS.

+1
source

This may or may not be interesting if you are not against jQuery (I did not write it):

jQuery BBQ: button bar and query library: http://benalman.com/projects/jquery-bbq-plugin/

0
source

Source: https://habr.com/ru/post/897537/