The onUnload After-Effect

I also know that the onLoad makes things happen when the HTML page fully loads. Well, the onUnload command makes something happen when the user unloads (leaves), the webpage.

It's best to keep the events that occur from the onLoad short, otherwise it could slow down the loading of the incoming page.

HTML file: Displayed by browser:
<body onUnload="alert('Leaving so soon?')">

<h4>When you click on the any of the green buttons at the bottom (or even refresh the page), the browser will unload this page, so the user will see a popup window.</h4>

</body>

When you click on the any of the green buttons at the bottom (or even refresh the page), the browser will unload this page, so the user will see a popup window.

Notice the placement of the single and double quotation marks. If I had used double quotes (instead of single) around the text, that would mean double quotation marks inside of double quotation marks. The browser would see the second set of doubles (out of the four) to be the end of the line and not understand what follows. An error would occur.

BackTable of ContentsNext