title: Javascript onbeforeunload function
body: <p>Folks I am trying to call this confirmation function on onbeforeunload event but its not getting called. What am I missing here? <br/>
  I am calling this inside the body tag: <code>&lt;body onbeforeunload="confirmation();"&gt;</code><br/>
  I also tried: <code>&lt;body onbeforeunload="return confirmation();"&gt;</code></p>
  
  <p>code: <br/></p>
  
  <pre><code>  function confirmation(){
    var answer = confirm('You have unsaved changes!!');
     if(answer == true)
      {
       alert('Bye Bye!!!');
      }
      else{
        alert('You are staying');
       return false;
      }
     }
  </code></pre>