[英]Open mailto link and close page
有没有办法让页面打开mailto
链接并立即关闭打开该链接的页面? 现在我有以下代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
window.location.href = "mailto:test@domain.com";
</script>
</head>
<body>
<a href="mailto:test@domain.com">Test</a>
</body>
</html>
当我导航到该页面时,邮件客户端已打开,但页面保持打开状态,这是我宁愿没有的。
您可以使用 Window.close() function 无论您的浏览器是什么,它都能正常工作。
<html>
<head>
<script type="text/javascript">
//window.location.href = "mailto:test@domain.com";
function openClose(url){
newTab = window.open(url) // Default open target is "_blank" aka new tab
newTab.close() // Window class have this method
// Automatically close the tab when email client starts
}
</script>
</head>
<body>
<a onclick="openClose('mailto:test@domain.com')" href="#">Test</a>
<!-- i set the "href" to "#" because of nothing :) -->
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.