When navigating away from the page, this function works when click refresh or closing the page. It does not work when the user clicks the back button. Does anyone know why this isn't working with the back button?
<script>
function PopIt() {
$("a.trigger").trigger('click');
window.onbeforeunload = UnPopIt;
return "Your changes have not been saved.";
}
function UnPopIt() { /* nothing to return */ }
window.onbeforeunload = PopIt;
$(document).ready(function () {
$("a[id!=trigger]").click(function () { window.onbeforeunload = PopIt;});
});
</script>
And Here is the HTML:
<div style="display: none;">
<a id="trigger" href="#aweber"> </a>
<div id="aweber" style="width: 250px; height: 400px;">
<script type="text/javascript" src="http://forms.aweber.com/form/90/1930283.js"></script>
</div>
</div>