1

I wan to remove parameter from URL without reloading or refreshing page.

I used below code for that, and it's working fine.

jQuery(document).ready(function($) {    
    window.history.pushState("", "", "/" );
});

But problem is if I click on browser back button I can see parameters in url.

Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
Praveen D
  • 2,337
  • 2
  • 31
  • 43
  • Because it is in the `array-like` state...Possible dupe of http://stackoverflow.com/questions/28028297/js-window-history-delete-a-state – Rayon Apr 05 '16 at 05:16

1 Answers1

7

That's because pushState adds a new entry to the browser history.

Use replaceState instead, to replace the current entry.

jQuery(document).ready(function($) {    
    window.history.replaceState("", "", "/" );
});
Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171