title: On Browser Back button handling of Hash URL change for SAPUI5/OpenUI5
body: <p>We have SAPUI5 Shell placed at a div inside an index.xhtml page. When user modifies the data in our application, user can perform 3 types of action for navigating away from the application:</p>
  
  <ol>
  <li>Press the cancel button in our application </li>
  <li>Type some other URL in the browser address bar </li>
  <li>Press the back-button in the browser bar.</li>
  </ol>
  
  <p>Our SAPUI5/Openui5 application works with the route concept (sap.ui.core.routing.Router) and hence the application has 'HASH URL'. </p>
  
  <p>For 1 &amp; 2, we made the following change and it works (based on Mozilla recommendation)</p>
  
  <pre><code>window.onbeforeunload = function(e) {
    var dialogText = 'Dialog text here';
    e.returnValue = dialogText;
    return dialogText;
  };
  </code></pre>
  
  <p>Mozilla Recommendation - <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload</a> </p>
  
  <p>But for pt.3 - when user presses BACK BUTTON, the HASH URL changes. Based on other discussion on Stackoverflow, playing around with browser history or disabling the browser back button is not working with Browser/Web World. </p>
  
  <p>Is there a way to do the following when browser back button is pressed:</p>
  
  <ol>
  <li>Show Popup giving user an option to Stay or Leave (informing changes in page will be lost)</li>
  <li>If user chooses to stay, then the URL remains including the 'HASH URL' part. </li>
  </ol>