<p><pre><code>    window.addEventListener(&quot;beforeunload&quot;, function () {
        alert(&quot;You just won our user lottery! Sign-up for a FREE iPad!&quot;);
        return false;
    }</code></pre>