关于把文章分享到facebook,google,twtter,whatsapp的总结
在网站的mete标签处还需要添加内容
http://hotintoday.com/content?id=92003">
//分享链接 http://hotintoday.com/content?id=92003
//分享标题 ${contentInfo.title } 根据自己情况而定 eg:content="分享的链接标题内容"
//分享描述 ${contentInfo.description } 根据自己情况而定 eg:content="分享的链接描素内容"
//分享图片 ${contentInfo.thumbnail} 根据自己情况而定 eg:content="图片链接地址"
以及
content="http://hotintoday.com/content?id=92003" />
//分享到facebook
function fbShare(contentId) {
u = document.getElementsByClassName("share_url")[0].content;
t = document.getElementsByClassName("share_title")[0].content;
window.open("http://www.facebook.com/sharer.php?u="+ encodeURIComponent(u) + "&t="+ encodeURIComponent(t), "sharer","toolbar=0,status=0,width=626,height=436");
"sharer","toolbar=0,status=0,width=626,height=436" 设定分享窗口视图高度
}
//分享到google
function googleShare(contentId) {
u = document.getElementsByClassName("share_url")[0].content;
t = document.getElementsByClassName("share_title")[0].content;
//window.open("https://plus.google.com/share?url="+encodeURIComponent(u), "sharer","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600");
}
//分享到twtter
function twitterShare(contentId) {
u = document.getElementsByClassName("share_url")[0].content;
t = document.getElementsByClassName("share_title")[0].content;
//window.open("http://twitter.com/home?status="+encodeURIComponent(u)+""+encodeURIComponent(t),"sharer", "toolbar=0,status=0,width=626,height=436");
}
分享到whatsapp
function whatsApp(contentId){
u = document.getElementsByClassName("share_url")[0].content;
t = document.getElementsByClassName("share_title")[0].content;
location="whatsapp://send?text="+ encodeURIComponent(t) + encodeURIComponent("\n\n"+u)+"&via=lopscoop";
}
页面调用的方法(html)
红色是内容重点,分享的地方,加上要分享的url,share_url 是要分享的地址
例如分享facebook,点击发布,就可以看到facebook 内容了