Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
Here is an example of using the unload
event. This is a method of the document object and is triggered when the page
unloads. In this example, the function will check to see if the browser accepts cookies.
// In HTML:
<element onunload="myScript"></element>
// In JavaScript:
object.onunload = function(){myScript};
// In JavaScript, using the addEventListener() method:
object.addEventListener("unload", myScript);