E.g. URL:

So how would you get the current URL using Javascript?

That is really easy, you can use window.location.href or just simply window.location.

But how do you replace the #hash at the end if it exists?

That too is quite easy, you can just do something like this:



window.location.href.substr(0, window.location.href.indexOf("#"))

So now that we have the value of the current URL how do we refresh the page with it?

window.location = window.location.href.split("#")[0];


window.location = window.location.href.substr(0, window.location.href.indexOf("#"));
Categories: ContentGeneral