on window close give alert javascript

Solutions on MaxInterview for on window close give alert javascript by the best coders in the world

showing results for - "on window close give alert javascript"
Alycia
29 Apr 2017
1let disableConfirmation = false;
2window.addEventListener('beforeunload', event => {
3  const confirmationText = 'Are you sure?';
4  if (!disableConfirmation) {
5    event.returnValue = confirmationText; // Gecko, Trident, Chrome 34+
6    return confirmationText;              // Gecko, WebKit, Chrome <34
7  } else {
8    // Set flag back to false, just in case
9    // user stops loading page after clicking a link.
10    disableConfirmation = false;
11  }
12});
13
14After Confimation if you want to send any ajax request and you have used jquery
15 $(window).on('unload', function() {
16   // async: false will make the AJAX synchronous in case you're using jQuery
17   axios
18     .get('ajax_url')
19     .then(response => {});
20 });
21
22And if no jquery is used you can use navigator, it require navigator library
23
24navigator.sendBeacon(url, data);
25
26
queries leading to this page
alert close javascripthow to close alert automatically in javascriptjavascript alert on window closealert when we close browser javascripthow to close alert in javascriptalert before window close javascriptclose an alert in jsjavascript alert and close windowhow to showalert when closing the browserwhen close window then alertclose window exxternal javascriptalert close button javascriptclose alert javascript automaticallyhow to close alert window in javascriptalert close functionhow to close an alert box in javascriptalert close event javascriptjs close alerthow to close alert raise in javascriptjs alert closejavascript to close alert boxalert on close javascriptclose alert using javascripton window close give alert javascriptshow alert when close browser in javascripthtml alert close windowjavascript on new window close alertclose alert ok close javascripthow to close alert javascripthow to close javascript alerton alert close javascriptclose alert jsalert when close window javascripthwo to close an alert using javascripthow to show alert when user tries to close browserclose an alert box automatically javascriptadd close button to alert javascripthow to close alert box automatically in javascriptjavascript alert on close windowhow to close an alert windowshow alert when close window js codejavascript alert won 27t closealert on close of windowclose window alert javascriptclose alert javascriptjs close alert on clickhow to close javascript alert automaticallyonperss ok js alert close windowhow to close alert in javascriptjavascript close page alertclose alert automatically javascriptalert on window close javascriptclose alert in javascriptjs alert will not closejs alert on closehow to add close button on alertjs code to close an alertclose site alert javascriptdetect when alert close javascriptclose window after alertwindow close alert javascriptbrowser close alert in javascriptjavascript window close alert messageclose alert by jsclose the alert box javascriptshow alert in browser window close eventalert before close window javascriptautomatically close alert box javascriptshow message when closing browserhow to close alert in jsalert close automatically javascriptwindow alert javascript closealert with close button json window close give alert javascript