> But THIS DOES NOT WORK:
>
> $(document).ready(function() {
>
>     $(window).unload(function() {
>         $.blockUI({ message: $('#question'), css: { width:
> '275px'} });
>     });
>
> });
>
> Any advice or suggestions are much appreciated.

The unload event does not give you an opportunity to display modal
dialogs like this.  You need to look at using the
window.onbeforeunload event.  For example:

window.onbeforeunload = function() {
    if (isDirty) {
        setTimeout(function() {
            $.blockUI({ message: '<h1>Saving changes...</h1>' });
            // code that saves changes goes here
        }, 200);

        // this is the message the browser will display for you
        return 'You have unsaved changes.';
    }
};



Reply via email to