2016-08-31 142 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/