Wix-location query persists once used

Once you have made a call to wix-location.to() with a url that contains a query, then every subsequent link, even from the menu or buttons, has the query appended.
This happens even after editing the site, republishing, and reloading the page!
And if you call wix-location.to() with a url with a different query, then that query just gets appended to the first.

www.mysite.com/admin?boatname=FRED&dummy2=DUMMY2&dummy=DUMMY

These three query parameters are after the site has been edited twice, republished,and reloaded.
There appears to be no way to clear the query.
Amazing.

2 Likes

:scream: oh no! Does anyone have any workarounds for this?

Close the tab |->>
Shake it Off with Taylor Swift comes to mind
Light relief: Dover Police DashCam Confessional (Shake it Off) - YouTube

There is no current way to clear a query in a wix URL unfortunately

Why do we all have to waste our time chasing this behaviour?
Why don’t Wix either

  • document the ‘feature’; so we can avoid using url queries

  • disable it until it is usable.
    ??

A workaround (which I was using before I decided to be ‘clever’ and use a url query) is to store the needed parameter(s) in either session or local storage. Then to ‘get’ it on the target page, and, importantly, clear it.

//Before call to wixLocation.to(url)
local.setItem('parameterName', parameterValue)

// and on the target page
let parameterValue = local.getItem('parameterName');
local.setItem('parameterName', ''); // forget the parameterValue for the next time this page loads

Hi

There is a way to remove the query from the URL and continue browsing in the same tab. You just need to use the entire URL like this:

export function button1_click(event) {
    wixLocation.to(`https://dudelemonweb.wixsite.com/userid/no-parameter`);
}

See it for yourself here: https://dudelemonweb.wixsite.com/userid/basic-page

& If you are concerned: No, it is not counted as 2 sessions on Google Analytics.