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:
- Detect whether it is a normal link or email link.
- If it is a normal link, redirect the page to that link.
- 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.