onunload = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The onunload event occurs once a page has unloaded (or the browser window has been closed).

Summary

Bubbles No
Cancelable No
Supported HTML tags: <body>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<h1>Welcome to my Home Page</h1>

<script>
document.getElementsByTagName("BODY")[0].onunload = function() {myFunction()};

function myFunction() {//from w w w  .  ja  v  a 2s .c o m
    console.log("here");
}
</script>

</body>
</html>

Related Tutorials