title: jQuery beforeunload custom pop up window for leaving a page
body: <p>Hi I would like to customize my pop up for leaving a page, is there any simple way to do that?</p>
  
  <p>I am using simple jQuery</p>
  
  <pre><code>$(document).ready(function() {
      var myPopUp = $('#pop-up').css('display', 'block');
      $(window).bind('beforeunload', function(){
        return 'load my pop up here instead of the default browser message';
      });
  });
  </code></pre>
  
  <p>my html for the pop up is which is hidden by default</p>
  
  <pre><code>&lt;div id="pop-up"&gt;
    &lt;h2&gt;Are you sure wanna leave&lt;/h2&gt;
    &lt;a href="#"&gt;Leave&lt;/a&gt;
    &lt;a href="#" class="close"&gt;Stay&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks</p>