Forum Moderators: open
Product Details page is an ordinary static html page whilst product listing is a dynamically created page.
Product Details page has a link "Back to listing".
If the user arrived to product detail page from one of the listing pages, then I want to go back to appropriate listing page (can use js history.back here)
However, if the user has arrived to Product Details page directly (from search engine, from Bookmarks or by typing in URL), then I want "Back to listing" to take the user to the first page of product listing.
How do I achieve this in static html page? I presume javascript and cookie? Does anyone know the piece of code as I am not js expert.
history.previous possibly using a regular expression to see if it came from your site through linking. If it did, then you'd go back in history with history.back() otherwise you can change the location: document.location = '/path/to/page'. Note that none of this will work if javascript is disabled. Take a look and see what you can do. :)