-1

I would like a script that refreshes a page when required and also strips out anything after and including the ? in the url.

Is this possible with javascript?

Somk
  • 11,869
  • 32
  • 97
  • 143
  • 1
    check if this works :- `var pathname = window.location.pathname; var newlocation = pathname.split(?)[0]; window.location.href = newlocation;` – streak Apr 30 '14 at 11:05
  • 1
    possible duplicate of [In Javascript, how do I reload the page without the query parameters?](http://stackoverflow.com/questions/7241851/in-javascript-how-do-i-reload-the-page-without-the-query-parameters) – Daniel Apr 30 '14 at 11:07

2 Answers2

1

Yes, you can.

var url = window.location.href.replace(/\?.*/g,"");

OR just use:

var url = window.location.pathname;
Amit Joki
  • 58,320
  • 7
  • 77
  • 95
0

This should do

window.location = window.location.href.split("?")[0];

or

window.location = window.location.pathname;
Jonast92
  • 4,964
  • 1
  • 18
  • 32