I think your best option is to use location.hash as a JavaScript router. Basically change the hash, observe the changes in the hash, and if the hash is a certain value, do something. Then, when the leaves and strokes used are โreturnedโ, they return to the page with the previous hash, in which case you can determine which version of the page they were included in and recreate.
<div id="tableDiv" style="display:none;" > <table> <td>something</td> </table> </div> <input type="button" value="Show" onClick="showTable()"/> <script type="text/javascript"> function showTable(){ location.hash = "#show"; </script>
There are many other options like cookies or localstorage.
Check out this plugin:
https://github.com/addcms/addHashRouter
Using this solution, you can do something like this:
HTML
<div id="tableDiv" style="display:none;"> <table> <td>something</td> </table> </div> <a href='#show'>Show Table</a>
Javascript
$add.UI.hashRouter.add("show", function(){ document.getElementById('tableDiv').style.display = "block"; });
And then, if they click the "Back" button after moving from the page, it will still appear, and if they hit the "Back" button after the table is displayed, it will not "return" it if you did not add this:
HTML
<a href='#hide'>Hide Table</a>
Javascript
$add.UI.hashRouter.add("hide", function(){ document.getElementById('tableDiv').style.display = "none"; });
And then you can use the show / hide buttons with browser navigation.
source share