'if there any event listener exist that trigger before the page reload?
hello I wondering is there any EVENTLISTENER exist in javaScript DOM that trigger right before the page reload not after. i was searching for a while and couldn't find any. I wanted to be sure so I asked it here thank for your time :)
Solution 1:[1]
Is there any event listener exist that trigger before the page reload?
Yes, the window.beforeunload event.
The beforeunload event is fired when the window, the document and its resources are about to be unloaded. The document is still visible and the event is still cancelable at this point. - MDN Definition
Keep in mind that as user JoshG commented, it will also fire on things such as page close.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
