When a user clicks on a button or link, I use the SimpleModal jQuery plugin to display a dialog to overlay the entire page, preventing the user from clicking another button or link during the delay before the next page loads. (I'd like to avoid this, but that's an issue for another day.)
After the next page displays, if the user clicks the Back button, the previous page still has the SimpleModal overlay displayed, preventing them from using the page. This is a problem.
How can I cause the SimpleModal dialog to close automatically either when the leaves the page or when the user clicks the Back button to return to the page?
I tried this without success:
$("body").unload(function() {
$.modal.close();
});
Thanks!
Wally
Update: Here's the solution that seems to work the best:
$(window).bind("beforeunload", function() {
$.modal.close();
});