Skip to Content
1
Former Member
Nov 24, 2017 at 01:53 PM

Browser back Button handle

2703 Views Last edit Nov 27, 2017 at 10:28 AM 2 rev

Hi All,

how can i handle the Browser Back Button in SAPUI 5? I want that when the user clicks on the button "back" of the browser, it is possible to display a popup that alerts that there is some data not saved.

Thank you,

Bilel

Edit (Solution):

document.onmouseover = function() {
     //User's mouse is inside the page.
     window.innerDocClick = true;
}
document.onmouseleave = function() {
    //User's mouse has left the page.
    window.innerDocClick = false;
}
window.onhashchange = function() {
   if (window.innerDocClick != false) {
      window.innerDocClick = false;
   } else {
     //Browser back button was clicked
     me.checkDataModified(true);
  }
}