I want to make a registration form. After the registration is complete, I want to navigate to the page the user was on before he/she open the registration form, so the previous URL needs to be remembered.
I don’t want to use a lightbox. Is there any way to do this? Can you give me an example?
referrer won’t work here, because Wix site is an SPA (The referrer will only be useful, if you want to redirect to the last external page outside the your site).
Hey J.D., didn´t know that, thanks. So to answer Quinten´s question, what should he then do? Use a URL param from the triggering page, remember or store it, then read and go back?
IF you wanted to implement this in a clean way (without having to add seperate code to every page) you would add some code “store_this_page_name” at site level, after reading the (possible existing) former value, which would be the referrer.
This would work if there is no page change between form and submit. But if there is, then “referrer page” would hold the FORM, not the page before the form. Any ideas?
The question is what exactly you want to achieve:
If you want save the page you started from without having to copy the code, you can have the code in the site code panel and do something like:
import wixLocation from 'wix-location';
import {session} from 'wix-storage';
let formPaths = ["formP1", "formP2", "formP3"];
let currentPath = wixLocation.path[0];
if (!formPaths.includes(currentPath)){
session.setItem("lastPage", currentPath);
}