Reputation: 2517
My code is:-
<html>
<head>
<script>
function welcome()
{
alert("Successfully loaded");
}
function bye()
{
alert("Unload");
}
</script>
</head>
<body onload="welcome()" onunload="bye()">
</body>
when i execute this only the function for "onload()" is called. Can you tell me how to trigger "onunload()" event also...
Upvotes: 0
Views: 1718
Reputation: 19327
It really depends on what browser you test it
The onunload
event is supported in IE, Firefox, and Safari, but not supported properly in Chrome or Opera.
please try onbeforeunload
<body onload="welcome()" onbeforeunload="bye()">
</body>
https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload
Upvotes: 1