How to show the conformation popup when the user clicks on browser back Button. If he clicks on leave button, it should navigate to the previous page & if he clicks on cancel button it should be in the existing page.
I think there is no such way to detect browser back button clicked.Instead of this you may wrong your logic ondetroy action.Also check if this can help youHow to Detect Browser Back Button event - Cross Browser
Hi HARI PRASAD BODDU ,
Confirmation message in JavaScript on the back button from the device
Please refer to the forum discussion
I hope this might help you.
when the user clicks on browser back Button. I am showing a conformation box. In My Case Ok button is navigating to previous page and cancel button is also navigating to previous page. how to stop the cancel button navigating to previous page (When we click on cancel button it should stay in the same page).
Add JavaScript to Your OutSystems Page
Follow these steps to add the JavaScript to your OutSystems page:
2. JavaScript Code
// Function to show confirmation dialog and handle navigation
function handleBackButtonEvent(e) {
var confirmationMessage = 'Are you sure you want to leave this page?';
if (!confirm(confirmationMessage)) {
// User clicked "Cancel", push the current state to prevent navigation
history.pushState(null, '', location.href);
}
// Intercept back button using onpopstate event
window.onpopstate = function (e) {
handleBackButtonEvent(e);
};
// Ensure the initial state is added to the history stack
Not working for cancel button, it is going to previous page