How can I close a SimpleModal dialog when the user clicks the Back button?
        Posted  
        
            by Wally Hartshorn
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Wally Hartshorn
        
        
        
        Published on 2010-03-12T20:43:16Z
        Indexed on 
            2010/03/12
            20:47 UTC
        
        
        Read the original article
        Hit count: 264
        
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
© Stack Overflow or respective owner