How does JS monitor page refresh and shutdown?

many methods have been tried on the Internet. Is there any complete code that can be posted? Thank you!

Mar.29,2021

//
window.onbeforeunload = function (event) {
    var event = event || window.event;
    if (event) {
        event.returnValue = "";
    }
    return '?';
}

at present, it seems that this method can only be used, as long as your page has been manipulated, such as text box editing. It will trigger a reminder, but the prompt can only be pre-set by the browser and you cannot change it. For example, 'are you sure you want to close the window' above is of no use.

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-1e48b73-27214.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-1e48b73-27214.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?