On my website on the payment page if the user tries to page refresh shows the alert popup.
All browsers working properly but not show only Safari 14. If my console menu open that time working fine.
My code I tried option 1: Not working in safari 14
@HostListener('window:beforeunload', ['$event'])
unloadHandler($event) {
$event.preventDefault();
$event.returnValue = 'Your data will be lost!';
}
I also tried option 2: Not working in safari 14
window.addEventListener('beforeunload', function (e) {
e.preventDefault();
e.returnValue = '';
});
Both solutions working fine but not working in safari 14.
Please any solution.
Thank you