In a recent application, they wanted to store the last url within a page (or area) the user visited.
This codepen shows how to do it:
If you:
- click on
Last Dogs Pageand then selectdog 1, - then click
Home Page, - Then if you click
Last Dogs Pageagain, the selection ofdog 1will remain.
It works by listening to when the url changes and checking if the url’s data includes page: "dog". If it does, it saves that url.