JS: Can't close current window/tab after email client pops up
<p>Edited: I took a look at: <a href="http://stackoverflow.com/questions/2699401/user-clicks-link-in-email-it-opens-email-client-how-to-close-window-tab">User clicks link in email, it opens email client, how to close window/tab?</a></p>

<p>Just want to confirm, is there really no way to do it.</p>

<hr>

<p>My page acts as a "transition/intermediate page", it would either redirect to other page, or open email client.</p>

<p>"#myDiv" contains a link, it might be a normal link (eg: <a href="http://www">http://www</a>) or an email link (mailto:).The link is coming from DB.
What I wanted to do is:</p>

<ol>
<li>Detect whether it is a normal link or email link.</li>
<li>If it is a normal link, redirect the page to that link.</li>
<li>If it is a mailto link, open that email client (eg: outlook), then close the current window/tab.</li>
</ol>

<p>I got 1 and 2 working, but for 3, i could have the email client (ooutlook) come out. But It just didn't close the current window/tab.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&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;title&gt;Untitled Document&lt;/title&gt;

&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;


&lt;/head&gt;

&lt;body&gt;

&lt;div id="myDiv"&gt;
    &lt;a href="mailto:test@test.com"&gt;Here is a email address. This window/tab should be closed.&lt;/a&gt;
&lt;/div&gt;


    &lt;script type="text/javascript"&gt;
        var link = jQuery("#myDiv a").attr("href");
        if(link.indexOf("mailto:") == -1) {
            window.location = link;
        } else {
            opener=self;
            //alert('in else');
            window.location = link;
            self.close();
            window.close();
        }
    &lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Thanks in advanced.</p>
