onbeforeunload not working within unload
<p>I have wrote the following code to run the onbeforeunload within unload. However, this doesn't seem working. Does anyone know what's wrong about my code and anyway to make it work?</p>

<pre><code>$(window).unload(function () {
    if ($('.submitAction').val() == "" &amp;&amp; isChange) {
        window.onbeforeunload = confirmExit;
    }
});

function confirmExit() {
    return "If you have made any changes to the fields without clicking the Save button, your changes will be lost.  Are you sure you want to exit this page?";
}
</code></pre>
