Prev Demo
JavaScript
>
How To Execute A Function When Element/Object Is Unloaded In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body onunload="CallFunction()"> <h1>Onunload</h1> Enter your name: <input type="text" name="txtName" id="txtName" /> <input type="button" id="btn" name="btn" value="Submit" /> <a href="Add.htm">Go to Add page</a> <script> function CallFunction() { alert("Navigating the page."); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output