how can onunload work properly?
<p>The following html calls the alert when the page loads, for Chrome Safari Firefox and Opera, but I want it to be called when the page *unloads":</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
&lt;body&gt;
&lt;script&gt;
window.addEventListener("unload", alert('hey'));
&lt;/script&gt;
body
&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>What am I doing wrong?</p>