Reputation: 125
I have a web app that I'm building right now that needs to use a mailto: link for the tell-a-friend portion. The message body was too long for a URL, so I had it in a hidden form and am sending the form via jQuery.
Everything is working brilliantly, except that it is adding + signs where the spaces should go. I've tried unescaping, replacing "+" with spaces, but as soon as it gets to "mailto_form.submit();", the + signs get added to the subject and body.
Thanks in advance for any suggestions!
<form id="mailto_form" action="mailto:" style="visibility:hidden;position:absolute;height:1px;width:1px;" method="get">
<input type="hidden" name="Subject" value="{$tellafriend_subject|replace:'"':'"'}">
<input type="hidden" name="Body" value="{$tellafriend_body|replace:'"':'"'}">
<input type="submit">
</form>
$(".email_link").click(function(e) {
var mailto_form = $("#mailto_form");
var val = $("input[name=Subject]", mailto_form).val();
val = val.replace("[[[NAME]]]", firstname);
$("input[name=Subject]", mailto_form).val(val);
var val = $("input[name=Body]", mailto_form).val();
val = val.replace("[[[NAME]]]", firstname + " " + lastname);
$("input[name=Body]", mailto_form).val(val);
mailto_form.submit();
e.preventDefault();
});
Upvotes: 5
Views: 2860
Reputation: 29020
%20
Seems to be an issue of the iOS mail client. In lieu of +
, you can URL-encode a space as %20
. I just ran into the issue and %20 is my solution to it.
Upvotes: 5