I have a site with dynamic pages. I use wixLocation.to() from multiple locations to navigate to a dynamic page, and have discovered that this strips query params (and anchors) from the url when navigating. For example:
wixLocation.to(/dynamicPage?param=value)
wixLocation.to(/dynamicPage#anchor1)
both resolve to simply /dynamicPage
OK, but I really want to be able to have query params on dynamic my page’s url.
I thought I could add them after the navigation by adding the queryParams after the dynamic page has loaded:
$w.onReady(function () {
wixLocation.queryParams.add({ "param": "value" })
}
This works fine when navigating forwards, but it causes problems when using the browser’s Back button - back-navigation gets stuck on the page one is one. E.g. I successfully navigate from:
https://kevinthiele1.wixsite.com/ausfloras/wa
to
But then the Back button keeps me stuck on https://kevinthiele1.wixsite.com/ausfloras/profile/view/hibbertia?flora=wa
I’ve tested this in Chrome, Firefox and Edge, and all behave the same way)
This seems strange, because the Wix API reference for onReady() says ‘Sets the functions that run when all the page elements have finished loading.’ - so I would have thought that queryParams.add would run after Back has taken us back to the target page.
I’ll be grateful for any advice.
Note that on my live site I’ve removed the line that causes this behaviour, but I can always turn it back on at any time.