asp.net javascript redirect failure
<p>From my main app page, Default.aspx I am popping up another page with <code>window.open</code>. 
On that page I have a home link as a <code>HyperLink</code> that calls a <code>Javascript</code> function.</p>

<pre><code>&lt;asp:HyperLink id="lnkHome" runat="server" meta:resourcekey="lnkHome" NavigateUrl = " " onclick = "javascript:performRedirect()"&gt;
</code></pre>

<p>I am checking if the parent window is still running and if it is just closing this window, If not then redirecting back to the main window.</p>

<pre><code>function performRedirect() {
    if (parentExists()) {

        $("a[id$= lnkHome]").attr('href', 'window.close();');
    }
    else {

        $("a[id$= lnkHome]").attr('href', 'Default.aspx');
    }
}
function parentExists() {

    return (window.parent.location === window.location) ? false : true;
}
</code></pre>

<p>It works, but for some reason check fails and it always redirects me to <code>Default.aspx</code> even if calling page is still open. What do I need to change here? Unfortunately I have to use <code>HyperLink</code> control. I am using ASP.NET 4.0</p>
