2

Is there a way i can remove a particular params from the url using push state with out refreshing: I know how to append some thing to the url:

  var url = $(location).attr('href');
  history.pushState(null, null, url + '&view=new_data');

But how would i remove a particular param from the url:

 history.pushState(null, null, url(without the &view param));
Micheal
  • 2,272
  • 10
  • 49
  • 93

1 Answers1

2

Try this :

 history.pushState(null, null, url.replace(/&view=.*(&?)/, '$1'));
Karl-André Gagnon
  • 33,662
  • 5
  • 50
  • 75