I have a webpage with a box that appears on the first visit.
In other parts of the site, there are 'back' buttons, and also, of course, the browser back button.
However, the when using the back button (browser or html), the box is visible again.
Is there a way to ensure that the box will not be displayed again when going back? Even removing the object completely with .remove()
doesn't work.
I've made an example jsbin here:
First, click the link to hide the box, then click the second link to go forward.
HTML:
<div id="hide-on-back">
Make this go away
</div>
<a href="#" id="hide-box">1. Click First To Hide</a><br/>
<br/>
<a href="http://jsbin.com/tipup/1/">2. Go Forward</a>
JS:
$(document).ready(function(){
$('a#hide-box').click(function(e){
e.preventDefault();
$('#hide-on-back').fadeOut();
});
});
HTML/JS (Back Button):
<a id="go-back" href="#" onclick="function(){history.go(-1);}">Go Back</a>