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:[email protected]?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.
Help?
EDIT:
I've also tried this:
<script>
function sendMail()
{
    var yourMessage = document.getElementById("message").value
    var subject = document.getElementById("selectList").value
    var mail="mailto:[email protected]?subject="+subject+"&body="+yourMessage;
    $(this).attr('href', mail);
}
</script>
Ive got that now, still not working.
Your code should look like this instead:
<script>
function sendMail()
{
    var yourMessage = document.getElementById("message").value;
    var subject = document.getElementById("selectList").value;
    document.location.href = "mailto:[email protected]?subject="
        + encodeURIComponent(subject)
        + "&body=" + encodeURIComponent(yourMessage);
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With