Using a Back Button | WixCreate | Wix Code - Corvid
 

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.

Elements:

Elements:

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

Demo:

(see right side of page)

Websites designed by WixCreate that use the above Wix Code:

Official Wix Expert & Wix Agency Partner

© 2020 by WIXCreate.com

I  All Rights Reserved  I  info@wixcreate.com  I  202-640-5440

facebook-2.gif