Mailto正文在IE中不填写
我正在使用 mailto 来允许客户提交产品报价信息。我正在尝试通过将 mailto 链接构造为字符串并连接报价信息,按照以下代码将报价自动填充到电子邮件正文中:
var quoteinfo = 'quote information here';
var link = '<a href="mailto:email?subject=subject&body=Please enter your contact information
and message here: %0A%0A%0AQuote:%0A' + quoteinfo + '">email</a>';
但是,在使用 IE 时,单击链接时,会生成电子邮件,但是仅显示显式添加的文本 - quoteinfo 变量中存储的任何内容都不会显示。我已验证最终链接确实包含所有报价信息 - 它只是没有出现在电子邮件中。由于电子邮件确实成功生成了部分文本,因此我不认为这是字符溢出问题(并且在任何情况下,即使 quoteinfo 变量中只有 30 个字符,也会发生这种情况。
也许这是特定于 :我很清楚现在有一种用表单代替mailto
的流行趋势——由于其他原因,我不能在这里这样做,所以请不要通过建议切换到表单来回应。
最后一点 我的链接的显示方式如下如下:
mailto:[email protected]?subject=Submission From Quote Creator &body=Please enter
your contact information and message here: %0A%0A%0AQuote:%0A#17350 - IFW 2-inch -
$829.00%0A
I am using mailto to allow submission of product quote information by customers. I am attempting auto-populate the quote into the email body by constructing the mailto link as a string, and concatenating the quote information, per the following code:
var quoteinfo = 'quote information here';
var link = '<a href="mailto:email?subject=subject&body=Please enter your contact information
and message here: %0A%0A%0AQuote:%0A' + quoteinfo + '">email</a>';
However, when using IE, when the link is clicked, the email is generated, but only the text that is explicitly added appears--nothing stored in the quoteinfo variable shows up. I have verified that the final link does contain all of the quote information--it just is not appearing in the email. Since the email does successfully generate with part of its text, I do not believe this is a character overflow problem (and in any case, this happens even with as few as 30 characters in the quoteinfo variable.
Perhaps this is a problem specific to the mail client?
A final note: I am well aware that there is a popular movement toward replacing mailto with forms--for other reasons, I cannot do that here, so please refrain from responding by advising a switch to a form.
A specific example of how my links would appear is as follows:
mailto:[email protected]?subject=Submission From Quote Creator &body=Please enter
your contact information and message here: %0A%0A%0AQuote:%0A#17350 - IFW 2-inch -
$829.00%0A
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
哈希符号 (#) 在 URL 中具有特殊含义(还记得锚点名称吗?例如 http://example.com#TopOfPage)。将其替换为
%23
。请参阅 W3 的 URL 编码参考
更好的是,JavaScript 可以使用
为您完成此操作编码URI()函数。
The hash symbol (#) has special meaning in URLs (remember anchor names? e.g. http://example.com#TopOfPage). Replace it with
%23
.See W3's URL Encoding Reference
Better yet, JavaScript can do it for you with the
encodeURI()
function.沿着这些线索,你得出了一个错误的结论。首先消除动态链接生成,然后使用静态 HTML 片段进行测试。如果这也不起作用,请发布不起作用的确切链接。也许您的引文中存在您不知道的无效字符。它可能以撇号开头吗?
从上面的代码来看,链接看起来像这样:
这工作得很好(测试过 IE9、Outlook2007)。
Somewhere along these lines, you are drawing a false conclusion. Start by eliminating the dynamic link generation, and test using a static piece of HTML. If that doesn't work either, post the exact link that doesn't work. Perhaps you have invalid characters in your quote that you are not aware of. Does it perhaps start with an apostrophe?
From your code above, the link would look something like this:
This works perfectly fine (tested IE9, Outlook2007).
除了将哈希 (#) 编码为 Fantabulum提到,我会检查他们正在使用哪个客户端。如果是 Outlook(从您的标签选择推断),他们可能需要运行“检测和修复”(通常位于“帮助”菜单中)。
运行“检测和修复”修复了我们内联网上类似链接的许多问题。通常,该问题是由损坏的文件/设置或某些其他程序劫持 Outlook 造成的 - 例如,Windows 更新恢复了 Outlook 已更改的注册表项。
In addition to URL encoding the hash (#) as Fantabulum mentions, I would check which client they are using. If it is Outlook (as inferred from your tag selection) they may want to run a "Detect and Repair" (usually found on the Help menu).
Running "Detect and Repair" has fixed a number of issues with similar links on our intranet. Usually the problem is the result of a corrupt file/setting, or some other program jacking with Outlook - e.g. a Windows update reverting a registry key that Outlook had changed.