top of page
Anchor 1

Wix Tutorial - Back button to a previously visited page, using Wix Code

This example shows how to use a Back Button for a site visitor to return to the previously viewed page. This only works when the site is published and doesn't work in the Editor.



  • Page Back Button: #BackButton  |  Pinned & Show on all pages

Wix Code (on 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");
    session.setItem("page", wixLocation.url);
    $w("#BackButton").link = previousPageURL;
    $w("#BackButton").target = "_self";


Page Back

(see right side of page)

Wix Code Back Button
bottom of page