0

When I remove one parameter from a URL with javaScript, then call:

window.location.assign(newURL);

It doesn't refresh the page without the parameter. It does nothing. How do I refresh the page without the parameter?

EDIT:

I have 2 parameters. It properly refreshes the page with all parameters removed. But it doesn't refresh the page when I leave one of the perameters in the URL. That is my problem.

The URL is:

https://thedomainsample.net/tablet/thePage.html?parameter1=388617&parameter2=true

Here is my code:

    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    const firstParameter = urlParams.get('parameter1');
    
    window.location = window.location.href.split("?")[0]+"?parameter1="+ firstParameter;

It basically removes the second parameter and tries to set the location to a URL with just the first parameter. It doesn't refresh the page, it does nothing.

user1435853
  • 633
  • 2
  • 8
  • 18

0 Answers0