2016-08-31 144 views
0

我想在我的博客文章页面添加“通过电子邮件分享此页面”按钮。在博客文章模板,这是我目前有:博客帖子URL +帖子标题mailto

<a 
href="mailto:?subject=Post title from XYZ blog&[email protected]&body=URL+to+page%2C+short+description&<?php 
echo curPageURL(); ?>">Share this page via email</a> 

我怎样才能使实际的文章标题和页面URL变量正确地显示在电子邮件输出?

回答

0

尝试

<a href="#" id="mail">Share this page</a> 

使用

window.onload=function() { 
    document.getElementById("mail").onclick=function() { 
    this.href='mailto:?subject='+ 
    document.title+'&[email protected]&body='+ 
    document.URL+'%0D%0A'+ 
    document.querySelector(".s22_richTextContainer").innerText++'%0D%0A'+ 
    '<img src="'+document.querySelector(".s25img img").src+'" />' 
    } 
} 

你们中许多人不得不放弃一些encodeURIComponent方法在那里

+0

谢谢mplngjan!我设法达到了这种状态:http://michaelpashbyantiq.wixsite.com/draft/single-post/2016/08/29/A-George-III-Bachelors-Chest-of-Diminutive-Proportions请参阅“通过电子邮件将此页发送给朋友“页面底部的链接 – spark

+0

是否有可能使邮件标题和第一图像出现在邮件正文中以提供给电子邮件输出? – spark

+0

现在来看看 – mplungjan

0

希望这能帮助别人在WordPress开发。

这是我加入到我的模板文件名(.php)

<a href="mailto:[email protected]?subject=<?php wp_title()?>&body=<?php 
print(urlencode(get_permalink())); ?>"> Email this blog post... </a> 

下面是一篇文章,介绍如何使用邮寄地址属性:https://css-tricks.com/snippets/html/mailto-links/