<body onunload="myFunction()"> - Javascript DOM Event

Javascript examples for DOM Event:onunload

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 onunload="myFunction()">

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

<script>
function myFunction() {//from  ww  w. j a  v  a2s .co m
    console.log("Thank you for visiting W3Schools!");
}
</script>

</body>
</html>

Related Tutorials