Closethepageandseewhathappens!
&n"/>Closethepageandseewhathappens!
&n">Home >Web Front-end >HTML Tutorial >In JavaScript, what is the purpose of the 'onunload' event?
The unload event is triggered when the page is unloaded (or refreshed). You can try running the following code to learn how to implement the onunload event in JavaScript.
<!DOCTYPE html> <html> <body onunload="newFunc()"> <p>Close the page and see what happens!</p> <p>This event may give unexpected results.</p> <script> function newFunc() { alert("Thank you!"); } </script> </body> </html>
The above is the detailed content of In JavaScript, what is the purpose of the 'onunload' event?. For more information, please follow other related articles on the PHP Chinese website!