how to auto close alert box javascript
window.setTimeout('alert("Message goes here");window.close();', 5000);
how to auto close alert box javascript
window.setTimeout('alert("Message goes here");window.close();', 5000);
on window close give alert javascript
let disableConfirmation = false;
window.addEventListener('beforeunload', event => {
const confirmationText = 'Are you sure?';
if (!disableConfirmation) {
event.returnValue = confirmationText; // Gecko, Trident, Chrome 34+
return confirmationText; // Gecko, WebKit, Chrome <34
} else {
// Set flag back to false, just in case
// user stops loading page after clicking a link.
disableConfirmation = false;
}
});
After Confimation if you want to send any ajax request and you have used jquery
$(window).on('unload', function() {
// async: false will make the AJAX synchronous in case you're using jQuery
axios
.get('ajax_url')
.then(response => {});
});
And if no jquery is used you can use navigator, it require navigator library
navigator.sendBeacon(url, data);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us