Product-Page - Add Button to GOTO previsited URL

Hey there guys,
I want to add a function to a Button on my Product-Page to GOTO the last visited Page.

Idea:

  • Create Button on Product-page “buttonZurueck”
    visitedUrl = current visiting baseUrl + urlPath (except it is a “product-page” url)
  • bind GOTO function with visitedUrl to “buttonZurueck”

Pseudo-Code: (onPageLoad?)
if (urlPath != product-page) {
let visitedUrl = wixLocation.baseUrl + wixLocation.path;
}
elementZurueck = document.getElementById(buttonZurueck);
bind on buttonZurueck function to (url: visitedUrl)

I have problems reaching the “buttonZurueck” as well as with the function to.
Any help would be much appreciated!

Best Regards
Rafael

Something like this:

if (urlPath !==  product-page) {
   let visitedUrl = wixLocation.baseUrl + wixLocation.path;
   $w(#(buttonZurueck).link = visitedUrl;  
}

Hello. How to do this but with browser button back?
I have 3 product-pages with redirect, but on click back in browser button user going back to redirected product page and back(like infinity loop)…