Popup window unload issue
<p>I have one popup window, when user opens and closes popup window simultaneously, it is giving script error. Below code is used in popup window.</p>

<pre><code>         &lt;html&gt;
    &lt;head&gt;
   &lt;script src="../../StaticContent/Scripts/jquery-1.7.2.min.js"
        type="text/javascript"&gt;&lt;/script&gt;

    &lt;script src="../../StaticContent/Scripts/jquery-ui-1.8.20.custom.js"
        type="text/javascript"&gt;&lt;/script&gt;
            &lt;script type="text/javascript" language="javascript"&gt;
             function CloseWarning() {
                        return "Do you want to close the window";
                    }
function onload()
{
}
        &lt;/script&gt;&lt;/head&gt;
            &lt;body onbeforeunload="return CloseWarning();" onload="onload();"&gt;


              //Some html



            &lt;script type="text/javascript" language="javascript"&gt;
                $(document).ready(
                    function() {
            //Some code
            });
            &lt;/script&gt;
            &lt;/body&gt;
            &lt;/html&gt;
</code></pre>

<p>I have tried degubbing, it is giving error at $(document).ready() line. I think because of closing the popup window before fully loading HTML is causing this problem. </p>

<p>Any clues???</p>
