wixLocation.url gives the url of the current page. How do I get the url of the referring page.
ie. if I have a link to page C from page A and page B, how do I know whether I came from page A or page B while I am in C?
I do this in the masterPage.js onReady()
let url = wixLocation . url ;
let prevUrl = local . getItem ( ‘prevUrl’ );
if ( url !== prevUrl ) {
:
:
local . setItem ( ‘prevUrl’ , url );
}
I also have code in my error404 page onReady() to get the url and prevUrl as follows:
let url = wixLocation . url ;
console . log ( ‘broken link=’ , url );
let prevUrl = local . getItem ( ‘prevUrl’ );
console . log ( ‘prev url =’ , prevUrl );
What I am not sure about is whether the masterPage onReady() will execute before or after the error404 page onReady() function.
Is there some other simple way to get the url of the referrer.