Solution 1 :

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>

Problem :

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?

Comments

Comment posted by How do I reload the page without the query parameters?

Does this answer your question?

Comment posted by tour

Hi Jip! Welcome to StackOverflow! Please take a look at our

Comment posted by vsync

Why can’t you just

By