Mailto使用Javascript? [英] Mailto using Javascript?
本文介绍了Mailto使用Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是javascript新手,以下代码不起作用:
I'm new to javascript and the following code isn't working:
<script>
function sendMail()
{
var yourMessage = document.getElementById("message").value
var subject = document.getElementById("selectList").value
var mail="mailto:chrisgreg23@googlemail.com?subject="+subject+"&body="+yourMessage;
window = window.open(mail, 'emailWindow')
}
</script>
我只希望打开一个已经完成主题和正文的邮件客户端窗口.
I just want a mail client window to open with the subject and body already done.
帮助?
我也尝试过:
<script>
function sendMail()
{
var yourMessage = document.getElementById("message").value
var subject = document.getElementById("selectList").value
var mail="mailto:chrisgreg23@googlemail.com?subject="+subject+"&body="+yourMessage;
$(this).attr('href', mail);
}
</script>
我已经明白了,但仍然无法正常工作.
Ive got that now, still not working.
推荐答案
您的代码应如下所示:
<script>
function sendMail()
{
var yourMessage = document.getElementById("message").value;
var subject = document.getElementById("selectList").value;
document.location.href = "mailto:chrisgreg23@googlemail.com?subject="
+ encodeURIComponent(subject)
+ "&body=" + encodeURIComponent(yourMessage);
}
</script>
这篇关于Mailto使用Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文