title: Jquery handle logourt on window close method
body: <p>I have created a popup window and I am trying to fire an event on close in order to <code>logout()</code> the user.</p>
  
  <p>My code as follows:</p>
  
  <pre><code>$(document).ready(function()
  {
      $(window).bind('beforeunload', function() {
          return confirm("");
      }); 
  });
  </code></pre>
  
  <p>When I close the close button I am getting like that:</p>
  
  <p><a href="https://i.stack.imgur.com/lp0UT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lp0UT.png" alt="enter image description here"></a></p>
  
  <p>From where the <strong>false</strong> coming from? And <strong>I want to put my on message</strong> instead of <code>Are you want to leave this page?</code></p>
  
  <p>If I click the Leave this page button the there should be a provision to call <code>logout()</code> or just stay on page otherwise.</p>
  
  <p>Please guide me.</p>