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.

mhall
  • 3,671
  • 3
  • 23
  • 35
artur
  • 675
  • 1
  • 6
  • 12
  • @Jordan it looks like artur has tested the answer given to that post, check his question. – DWB Feb 23 '15 at 23:25
  • Yes I already have tested this answer but it doesn't work for me. – artur Feb 23 '15 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. – Jordan Running Feb 23 '15 at 23:34

2 Answers2

0

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

IAteYourKitten
  • 968
  • 1
  • 6
  • 13
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?

Community
  • 1
  • 1
Voodoo22
  • 28
  • 4