Javascript examples for DOM:Event
When is the page left/unloaded, handle load, unload and before unload event
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function testLoad() {/* w ww .j av a 2 s .co m*/ console.log('loaded'); } function testBeforeUnload() { return "test before unload event"; //console.log("test"); } function testUnload() { console.log("test unload event"); } </script> </head> <body onload="testLoad()" onunload="testUnload()" onbeforeunload="return testBeforeUnload()"> </body> </html>