title: alter alert dialog on window close
body: <p>What I'm trying to accomplish is the following:</p>
  
  <p>If the user tries to close the window the alert pops up and I want to change the text so a user has the option to leave the page or can choose to stay and redirect to another page. </p>
  
  <p>Probably searching for it in the wrong way but I really can't find anything that works.</p>
  
  <p>What I have so far:</p>
  
  <p><code>window.onbeforeunload = function() { /*...*/ }</code></p>
  
  <p>I need to know how to adjust the text of the alert and add a handler on the stay button.</p>