English 中文(简体)
缩略语
原标题:JS: Can t close current window/tab after email client pops up
  • 时间:2011-11-21 19:45:00
  •  标签:
  • javascript

Edited: I took a look at: User clicks link in email, it opens email client, how to close window/tab?

只想证实,这真的没有办法。


我的网页是“过渡/中页”,要么改用其他网页,要么是公开的电子邮件客户。

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

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

我工作了1和2,但就3而言,可以找到电子邮件客户(ooutlook)。 但 它只是关闭了目前的窗口/表格。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>


</head>

<body>

<div id="myDiv">
    <a href="mailto:[email protected]">Here is a email address. This window/tab should be closed.</a>
</div>


    <script type="text/javascript">
        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();
        }
    </script>

</body>
</html>

Thanks in advanced.

问题回答

如果你打算打开窗户(例如利用窗户开放)。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签