How to check for dirty flag
<p>I was wondering what is the best way of checking if a page is dirty if a user chooses to navigate it from it.  For example, there is a registration form and the user enters all his information.  Then accidentally clicks on a link to navigate from it.  </p>

<p>I found this on the web where it checks if a page is dirty if a person makes changes to any of the form input values. </p>

<pre><code>&lt;script type="text/javascript"&gt;
var isDirty = false;
var msg = 'You haven\'t saved your changes.';
$(document).ready(function(){
    $(':input').change(function(){
        if(!isDirty){
            isDirty = true;
        }
    });
    window.onbeforeunload = function(){
        if(isDirty){
            return msg;
        }
    };
});
&lt;/script&gt;
</code></pre>

<p>So this works great.  But how do I exclude some links that are pop-ups? Is there a better way of doing this?</p>
