-2

I want to create a button were people can click on to get redirected to a new url based on the current url.

/collection/?filter_kleur=grijs&query_type_kleur=or

I want everything after collection/ to be removed. What is the easiest way to fix this?

vsync
  • 118,978
  • 58
  • 307
  • 400
  • 2
    Does this answer your question? [How do I reload the page without the query parameters?](https://stackoverflow.com/questions/7241851/how-do-i-reload-the-page-without-the-query-parameters) – 0stone0 Jan 15 '21 at 15:28
  • Hi Jip! Welcome to StackOverflow! Please take a look at our [tour] to get a better understanding about how to add a [mre]! – 0stone0 Jan 15 '21 at 15:30
  • Why can't you just *hard-code* the `href` attribute with `/collection/NAME` ? – vsync Jan 15 '21 at 15:35

1 Answers1

0

You could use the URL api.

const url = new URL('https://test.be/collection/?filter_kleur=grijs&query_type_kleur=or');

const output = document.getElementById('output');
output.innerHTML = url.host + url.pathname;
<output id="output"></output>