0

I have an empty query string on the end of my url after removing the original query string: http://example.com?

Setting window.location.search = ''; doesn't get rid of the question mark, only the contents of the query string. Is there any way to remove the question mark at the end of the url?

pedrum golriz
  • 513
  • 8
  • 27
  • Look into pushState: e.g. `window.history.pushState({}, '', window.location.pathname);` – Alfredo Delgado Oct 08 '15 at 15:42
  • @AlfredoDelgado I voted to reject your edit, because it is not clear if the author's intent is to alter the currently displayed URL. Rather than editing your assumption into the question and fundamentally changing the problem statement of the question, better to ask for clarification from the OP. – Chris Baker Oct 08 '15 at 16:20
  • @ChrisBaker He provided enough details to reproduce his problem in a browser — no assumptions on this end. – Alfredo Delgado Oct 08 '15 at 16:53
  • You assumed his goal was to replace the URL in the address bar, and edited the question to reflect that assumption. He does not specify what he wants to do with the now-query-stringless URL once he removes the question mark. You may be right (personally, I believe you *are*), all I'm saying is that you should ask the OP before changing the essence of the question. Other community reviewers agreed, and that's why your edit was rejected. Have a good one. – Chris Baker Oct 08 '15 at 17:01

0 Answers0