function sendMail() {
var link = "mailto:myemail@testemail.com.hk"
+ "&subject=" + escape("This is my subject")
+ "&body=" + escape("This is my body")
;
window.location.href = link; }
<a href="www.google.com" target="_self" onclick="sendMail(); return false">Link</a>
i had try the above code, but when i click the link, it just can send email, but the page is not go to www.google.com website, how can i let it run together? many thanks.
答案 0 :(得分:0)
好吧,您可以做的一件事就是更改它在哪个页面上运行-在新标签页中打开mailto
链接,然后在当前标签页中打开www.google.com
:
function sendMail() {
var link = "mailto:myemail@testemail.com.hk"
+ "&subject=" + escape("This is my subject")
+ "&body=" + escape("This is my body");
window.open(link, "_blank");
}
<a href="www.google.com" target="_self" onclick="sendMail(); return false">Link</a>
答案 1 :(得分:0)
尝试以下代码:
function sendMail() {
window.location.href = "mailto:abc@example.com?subject=This is my subject&body=This is my body";
setTimeout(function() {
window.location.href = "https://Google.com";
})
}
<button onclick="sendMail()"> Link </button>