JavaScript – Reload window without query string

Here is a way to reload/refresh the current web page in JavaScript, removing any query string parameters in the process:

window.location = window.location.pathname;

This preserves protocol selection (HTTP/HTTPS) and is more succinct than the existing methods I found on Google. Note that this will remove the fragment as well (#part).

More information about the location object


comments powered by Disqus