Hi I’m trying to implement a back button in a dynamic category page to take the user in the last location. Here is the code in the screen shot below. Any help is deeply appreciated. Thanks
TIA
Hi I’m trying to implement a back button in a dynamic category page to take the user in the last location. Here is the code in the screen shot below. Any help is deeply appreciated. Thanks
TIA
Can anyone help out pls?
Hi,
It looks like an issue in our side. We will update in this thread when it’s fixed.
Roi.
I see. Thanks a lot!
It has been 9 months. There have been many people complaining about this issue. Having access to the referrer is fundamental. Would you please fix the bug where wixWindow.referrer always returns a null on the live site.
Look at this link:
Try something like this as stated on that link:
This example demonstrates how to use session storage to know which page is the page a site visitor previously visited. The code below needs to be placed in the Site tab so that it runs on all your site’s pages. The code retrieves the URL of the page a visitor previously visited from session storage. It then stores the URL of the visitor’s current page in session storage. When the visitor navigates to another page, this stored URL is retrieved as the previous page URL.
// In Site tab
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
let previousPageURL;
$w.onReady(function () {
previousPageURL = session.getItem("page");
session.setItem("page", wixLocation.url);
});
This is another back button code example from Yisrael (Wix Mod):
This example shows how to implement a Back Button to allow the site visitor to return to the previously viewed site page. This feature will only work for a published site and will not work in the Editor.
Note that the code is added to the Site tab of the code so that it is available on all pages.
// In Site tab
import wixWindow from 'wix-window';
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
let previousPageURL;
$w.onReady(function () {
previousPageURL = session.getItem("page");
console.log(previousPageURL);
session.setItem("page", wixLocation.url);
$w("#btnBack").link = previousPageURL;
$w("#btnBack").target = "_self";
});
Or you can check out this tutorial too:
Wix Code Tutorial: Creating Previous and Next Buttons for a Dynamic Item Page with Code
Thanks for the work around. For my case where I had a policy page link everywhere, I decided to put it in a light box. I am also using the dynamic page buttons, and in another place I use a slider with page content on each slide, using next and back buttons to change slides. Wish I had thought about session data before I got into that tangled mess.
There are still situations where the referer is needed. For example, you may want to identify where people are coming from for particular pages.
The wixWindow.referrer has some weird quirks
For example, when navigating to my wix site page from an external link, referrer = null unless I right-click on the link and select “open in new tab”