Javascript onbeforeunload- Show an image on Exit
<p>I am using following code so that if user closes the browser button it shows a confirmation box, whether to stay on page or not.</p>

<p>What I want to do is if someone closes the browser it should show an image, with "yes" or "no" options. When "yes" is clicked it should close the browser and if "no" is clicked it shouldn't close the browser. The Image has to be shown in the same window not in any popup. Is it possible to do it or am I expecting too much from JavaScript?</p>

<pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

&lt;script type="text/javascript"&gt;
var exit=true;
    function confirmExit()
            {
            if(exit)
            {
            window.location.href = "?p=exit";
            }
            if(exit)
            return "Wait! Don't Leave Empty Handed!\n\nThank you for taking the time to check out our offer! Before you go we have a complimentary crash to help you succeed. Click the 'Cancel' or 'Stay On This Page' button if you're interested!";
            }
&lt;/script&gt;
&lt;/head&gt;
&lt;body  onbeforeunload="return confirmExit()"&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
