Alex Rivera | Logout

jquery removing everything after question mark in url

Asked 2012-07-16T06:14:42.070
12

I was wondering if I can remove everything after a question mark in a URL?

http://www.site.com?some_parameters_continue_forever

can I just use .remove()? What would need to be put inside the parameters?

Thanks

Edit
Report

1 Answer

13

Since the url is controlled by the browser when you change the url the page will reload. Still for what you want to do, on pages where you don't need the stuff after the ? mark type..

window.location = "http://www.mysite.com" //or whatever your site url is

To dynamically do this you can use the below function and then use window.location

function getPathFromUrl(url) {
  return url.split("?")[0];
}

Note: When you change the url the page will refresh.

answered 2012-07-16T07:08:14.407

Your Answer