iPhone中的mailto链接正在添加加号而不是空格 [英] mailto links in iPhone are adding plus signs instead of spaces

查看:145
本文介绍了iPhone中的mailto链接正在添加加号而不是空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在构建的Web应用程序,该应用程序需要使用mailto:链接作为告诉朋友"部分.邮件正文对于URL来说太长了,因此我以隐藏形式保存它,并通过jQuery发送该表单.

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.

一切正常,但要在空格处加+号.我已经尝试过转义,用空格替换"+",但是一旦它变成"mailto_form.submit();",+号就会被添加到主题和正文中.

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:'"':'&quot;'}">
    <input type="hidden" name="Body" value="{$tellafriend_body|replace:'"':'&quot;'}">
    <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();
});

推荐答案

使用%20

似乎是iOS邮件客户端的问题.代替+,您可以将空格URL编码为%20.我刚遇到这个问题,而%20是我的解决方案.

Use %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.

这篇关于iPhone中的mailto链接正在添加加号而不是空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆