使用mailto:时是否可以设置电子邮件的主题/内容?
ask by Jiew Meng translate from soYes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm
(是的,请使用mailto查看所有提示和技巧: http : //www.angelfire.com/dc/html-webmaster/mailto.htm)
mailto subject example:
(mailto主题示例:)
<a href="mailto:no-one@snai1mai1.com?subject=free chocolate">example</a>
mailto with content:
(mailto内容:)
<a href="mailto:no-one@snai1mai1.com?subject=look at this website&body=Hi,I found this website and thought you might like it http://www.geocities.com/wowhtml/">tell a friend</a>
As alluded to in the comments, both subject
and body
must be escaped properly.
(正如评论中提到的那样, subject
和body
必须适当地转义。)
encodeURIComponent(subject)
on each, rather than hand-coding for specific cases. (在每种情况下都使用encodeURIComponent(subject)
,而不是对特定情况进行手工编码。)
As Hoody mentioned in the comments, you can add line breaks by adding the following encoded sequence in the string:
(如Hoody在评论中所述,您可以通过在字符串中添加以下编码序列来添加换行符:)
%0D%0A // one line break