title: Help required on onbeforeunload or click on browser back button
body: <p>If a user clicks the browser's back button, then I want a prompt to appear and ask for confirmation. If the user clicks 'OK', then it should navigate to <code>xx.html</code>. If the user clicks 'Cancel', then it should prevent the navigation.  How can I do this?</p>
  
  <p>Note: Already I tried the <code>onbeforeunload</code> method, but it is working for all the navigation actions.  For Example, clicking the link on the page will also fire this event and show the message to the user.</p>