Html Mailto:正文格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11507387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mailto: Body formatting
提问by TheLegend
Possible Duplicate:
mailto link multiple body lines
可能重复:
mailto 链接多个正文行
Just a quick question. I am creating a website for a charity and they have a section on the site where people can give some suggestions for how they could raise more money for their cause. Their site is just plain HTML, JS and CSS to keep it light-weight. I added a mailto:
that will allow people to send them an e-mail, but they would like some more information like their name and their contact details. I want to know if there is a way to format the body so that there are new lines:
只是一个简单的问题。我正在为一个慈善机构创建一个网站,他们在网站上有一个部分,人们可以在那里就如何为他们的事业筹集更多资金提出一些建议。他们的网站只是简单的 HTML、JS 和 CSS,以保持它的轻量级。我添加了一个mailto:
允许人们向他们发送电子邮件,但他们想要更多信息,例如他们的姓名和联系方式。我想知道是否有办法格式化正文以便有新行:
name:
email:
tel:
postal address:
thank you!
谢谢你!
Here is what my mailto
looks like now. any help or suggestions are welcome:
这是我mailto
现在的样子。欢迎任何帮助或建议:
<a href="mailto:[email protected]?subject=Suggestions&body=Your%20suggestions%20are%20really%20important%20to%20us%20,thanks!">Send suggestions!</a>
回答by Curt
Use %0D%0A
for a line break in your body
使用%0D%0A
在你的身体一个换行符
- How to enter line break into mailto body command(by Christian Petters; 01 Apr 2008)
- 如何在 mailto body 命令中输入换行符(Christian Petters;2008 年 4 月 1 日)
Example (Demo):
示例(演示):
<a href="mailto:[email protected]?subject=Suggestions&body=name:%0D%0Aemail:">test</a>?
^^^^^^
回答by Madara's Ghost
From the first result on Google:
从谷歌上的第一个结果:
mailto:[email protected]_t?subject=Header&body=This%20is...%20the%20first%20line%0D%0AThis%20is%20the%20second
回答by RobIII
Forget it; this might work with Outlook or maybe even GMail but you won't be able to get this working properly supporting most other E-mail clients out there (and there's a shitton of 'em).
算了吧; 这可能适用于 Outlook 甚至 GMail,但您将无法使其正常工作以支持大多数其他电子邮件客户端(并且有很多)。
You're better of using a simple PHP script (check out PHPMailer) or use a hosted solution (Google "email form hosted", "free email form hosting" or something similar)
您最好使用简单的 PHP 脚本(查看PHPMailer)或使用托管解决方案(谷歌“电子邮件表单托管”、“免费电子邮件表单托管”或类似内容)
By the way, you are looking for the term "Percent-encoding" (also called url-encodingand Javascript uses encodeUri/encodeUriComponent(make sure you understand the differences!)). You will need to encode a whole lot more than just newlines.
顺便说一下,您正在寻找术语“百分比编码”(也称为url 编码,Javascript 使用encodeUri/ encodeUriComponent(确保您了解差异!))。您将需要编码的不仅仅是换行符。