0

how does 'onunload' event works?

can ny1 give me a eg in form of a code?

27th Mar 2018, 7:37 AM
2+2=4
2+2=4 - avatar
4 Respostas
+ 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);
27th Mar 2018, 4:54 PM
Baraa AB
Baraa AB - avatar
+ 2
eg:'onload' event works when we load a particular code in output. similarly how does 'onunload' event works
27th Mar 2018, 4:52 PM
2+2=4
2+2=4 - avatar
+ 1
<body onunload="alert('Thank you. Please come back to this site and visit us soon, ok?')">
27th Mar 2018, 9:30 AM
Mike Choy
Mike Choy - avatar
+ 1
'm asking how it works?
27th Mar 2018, 4:50 PM
2+2=4
2+2=4 - avatar