Disabling back button of browser

0
Hi reader I want to disable back button for a particular page(T&C page in my case). I have used this JS code for a page      window.location.hash = "no-back-button";     // Again because Google Chrome doesn't insert     // the first hash into the history     window.location.hash = "Again-no-back-button";      window.onhashchange = function(){         window.location.hash = "no-back-button";     }   It works fine for other pages in my project but not for T&C page. Please tell me if i have to do some change or let me know any other information is required Thanks
asked
1 answers
0

Hi,

To control the functionality of the back button in a Mendix application, you can use JavaScript code in a snippet. 


// Disable the back button
window.history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function(event) {
  window.history.pushState(null, document.title, location.href);
});

// Customize the back button behavior
window.addEventListener('popstate', function(event) {
  // Add your desired functionality here
  // For example, you can redirect to a specific page:
  window.location.href = 'path/to/your/page';
});

The above code works for page, if it is a pop up,change the close action on page properties.

Hope it helps!!!

answered