title: how to unbind onbeforeunload event on javascript function call and page refresh
body: <p>Please help me how to unbind onbeforeunload event on javascript function call .
  Also I want to unbind onbeforeunload on page refresh.
   Actually I want to give pop up alert on page exit .For this I have successfully unbinded onbeforeunload from form submit button and anchor tags. Kindly help me. The code I have used is </p>
  
  <pre class="lang-js prettyprint-override"><code>var jQuery = jQuery.noConflict();
  jQuery(document).ready(function() {
    jQuery(window).bind("onbeforeunload", function() {
        return confirm("Do you really want to close?")
      }
    );
  
    jQuery('a').on('click', function() {
      jQuery(window).unbind('onbeforeunload')
    });
  
    jQuery("form").submit(function() {
      jQuery(window).unbind('onbeforeunload')
    });
  });
  </code></pre>
  
  <p>Thanks</p>