0

I'm using this code

$("#reset_filter").on("click", function(e) {
    window.location.hash = "";
    window.location.reload();
});

for reset the URL on the page but because of (window.location.hash) on the end of the URL I always get #. Is it possible somehow to remove the hash from the URL? I already have tried with

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

and

window.location.href.split('#')[0]

but it was not working, any proposition and help please.

3
  • @Jordan it looks like artur has tested the answer given to that post, check his question. Commented Feb 23, 2015 at 23:25
  • Yes I already have tested this answer but it doesn't work for me. Commented Feb 23, 2015 at 23:27
  • 1
    Read the answer under "With regards to your edit." The given code works if you assign the result to window.location, but it triggers a page refresh, hence the addendum. Also read the second-ranked answer. It may not solve artur's problem, but it gives the only correct answer (though I'd love to be proven wrong), and this question is still a duplicate. Commented Feb 23, 2015 at 23:34

2 Answers 2

0

No. If you explicitly tell javascript to set a hash-location there will be a hash in the location.

Sign up to request clarification or add additional context in comments.

Comments

0

you can just make the page reload or you use

Remove hash from url

this:

< a href='#anchor' onclick='return anchorJump(this.href)'>click

or

http://ajaxian.com/archives/ajax-tackle-the-refresh-button

but anyway what browser do you use?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.