How does js listen for browser closes and make pop-up prompts?

I have done the upload / download function, and now I want to achieve: when the upload / download is not completed, click to close the browser, the pop-up file is downloading / uploading, are you sure to close?

Jul.08,2021

refer to the API documentation.

window.onbeforeunload-Web API API | MDN- https://developer.mozilla.org.

the general idea is:

  • registers a closed window listening event for window when downloading / uploading
  • Log out of the listening event of this closed window after download / upload

how to solve the problem


window.onunload = function(){
 alert('?')
}
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-1b31b26-2b601.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-1b31b26-2b601.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?