title: Confirmation before closing of tab/browser
body: <p>How to ask confirmation from user before he leaves the page as in gmail?</p>
  
  <p>I searched for this question in various places, but all that they mention is the use of javascript <b>window.unload</b> &amp; <b>window.onbeforeunload</b>. Also it doesn't work in chrome most of the times as it gets blocked.<br/></p>