Back to pervious page or URL velo code not working

hello dears
is their any article on back to previous url velo code please

You wrote “not working” in the title - what have you tried?

a lot of codes such as
import wixLocation from ‘wix-location’;

$w.onReady(function () {
// Event handler for button click
$w(“#button43”).onClick(() => {
// Navigate back to the previous URL
wixLocation.back();
});
});

Makes sense this wouldn’t work
There’s no such thing
You can’t really guess your way into making things work, read the documentation
https://dev.wix.com/docs/velo/api-reference/wix-location-frontend/introduction

As for implementing a back button, I’d have two values saved in session storage - previousPage and currentPage
Whenever a page loads, it checks if currentPage is different than itself, and if so, sets previousPage to currentPage, and currentPage to the page being loaded

Then, you could simple have wixLocation send you to what’s saved in previousPage

Note it will not work the same as a browser’s back button, since after going back, currentPage will become the previous page, and previousPage will become the current, resulting it another back button sending you back and forth between those two pages, rather than heading back through your tab’s history

can you please share a code with me please

Always search the forum first for similar questions before posting your own.

1 Like