0
how does 'onunload' event works?
can ny1 give me a eg in form of a code?
4 ответов
+ 5
The onunload event occurs once a page has unloaded (or the browser window has been closed).
onunload occurs when the user navigates away from the page (by clicking on a link, submitting a form, closing the browser window, etc.).
Note: The onunload event is also triggered when a user reloads the page (and the onload event).
In HTML:
<element onunload="myScript">
In JavaScript:
object.onunload = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("unload", myScript);
+ 2
eg:'onload' event works when we load a particular code in output.
similarly how does 'onunload' event works
+ 1
<body onunload="alert('Thank you. Please come back to this site and visit us soon, ok?')">
+ 1
'm asking how it works?