如何通过mailto在电子邮件中突出显示链接

时间:2016-04-07 16:40:08

标签: javascript jquery html css

非常简单的问题:我有

 $('#email-link').attr('href', 'mailto:?subject=Checkout%20My%20Survey%20Results&body=' + encodeURIComponent(window.location.href));

我希望可以点击电子邮件正文的链接。有没有办法做到这一点?

2 个答案:

答案 0 :(得分:2)

只需将锚标记的HTML设置为电子邮件正文。



var emailBody = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean justo purus, iaculis id cursus quis, consectetur vel arcu. Sed iaculis sagittis elit, non tristique ex malesuada non. Etiam elementum lectus quis nunc efficitur blandit. Mauris luctus nunc a quam euismod, sit amet maximus tortor venenatis. Aliquam tempus convallis magna. Aenean nec lorem pellentesque, sollicitudin massa quis, ultrices lacus. Vestibulum egestas magna libero, vel facilisis arcu viverra eu. Nullam eget rhoncus mi, vel volutpat eros. Phasellus iaculis urna quam, vel porttitor dolor feugiat eu. Ut nec tincidunt nulla. Duis imperdiet molestie massa, id placerat ligula aliquet quis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi blandit, eros eget pretium porta, felis mi blandit nunc, at malesuada metus lorem non nunc. Integer sollicitudin libero at ante accumsan molestie. Morbi in ultricies magna. Sed et ullamcorper purus."
$('#email-link').attr('href', 'mailto:?subject=Checkout%20My%20Survey%20Results&body=' + encodeURIComponent(emailBody))
.html(emailBody);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="email-link"></a>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

尝试添加锚标记并将锚标记的href设置为window.location.href的编码uri

'mailto:?subject=Checkout%20My%20Survey%20Results&body=<a href="' + encodeURIComponent(window.location.href) + '">Survey Link</a>'