Conditional popup on html document close
<p>I have a content management page on my CMS on which I have a popup that warns the user on page close. It is a very simple warning implemented like so:</p>

<pre><code>window.onbeforeunload = function (e) {
     return 'Are you sure you want to close?';
} 
</code></pre>

<p>It works, but the problem is that the popup is shown even when the user clicks the same button. I am very new to document events so I have no idea how to do this, but I want the popup to only show when the page is being closed and not when it is being posted back.</p>

<p>Also I have not used JQuery in my website so please don't suggest it; I don't want to use a whole framework just for a popup.
.
Thanks.</p>
