How does JavaScript listen for page closure (non-refresh)?

< H2 > as mentioned above, we want to listen to the closing event of the page, but we will respond if we find that refreshing or closing will happen. < / H2 >

the following is the judgment code on the network, but it doesn"t seem to work. "Refresh or leave" will be printed all the time

.
window.onbeforeunload = function () {
    alert("");
    //  , ,  method
    // setTimeout(onunloadcancel, 3);
    if (event.clientX <= 0 && event.clientY < 0) {
      console.log("");
    }
    else {
      console.log("");
    }
    return "?";
  }

does JavaScript provide any solutions?

Jun.02,2021

refreshing the page is equivalent to closing and then opening it. It seems that you can't just listen for closed events. onunload doesn't work either. See if this helps you: http://udn.yyuap.com/forum.ph.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a3c2-2ba44.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a3c2-2ba44.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?