如何在Facebook上分享我的网站的内容 [英] How to share content of my website on facebook

查看:139
本文介绍了如何在Facebook上分享我的网站的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我有一个名为share的Facebook按钮。我想要的是,当用户点击该按钮时,我的网页的内容应该在他的墙上分享。我的代码就像我头上的页面标签:

I have a website and on that I have a facebook button named as share. I want that when user clicks on that button the content of my webpage should share on his wall. My code is like this in my head tag of page:

<script>
    function fbs_click(){
        u = location.href;
        t = document.title;
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
    }
</script>

我也知道 u = url 您的内容页面 t = title 或网站名称,这在正文标签内:

I also know that u= url of your content page t= title or site name and this is inside the body tag:

<a rel="nofollow" href="http://www.facebook.com/share.php?u=http://lums.edu.pk/event-detail/lecture-on-citation-management-and-referencing-1133"
class="fb_share_button" onclick="return fbs_click()" target="_blank"  
style="text-decoration:none;">Share</a>

?是我要分享的链接。
此代码为我打开一个共享页面,并且只分享我的网址而不是我的页面的内容。我的内容包括图像,小图和细节(我从数据库表中获取这些值)。请一些帮助我。

?u is the link I want to share. This code open a share page for me, and share just my url not the content of my page. My content includes an image, tittle and detail (I'm fetching these values from database table). Please some one help me.

推荐答案

最后我得到了我的解决方案。这是为我做的工作的实际代码。我是错误的处理我的链接。它应该是这样的

Finally I got my solution.This is actual code that is doing job for me . I was mis handleing ?u of my link.It should be like this

 ?u=http%3A%2F%2Fmywebsite.com%2Fcontent+of+my+page" target="_blank">this link</a>

这篇关于如何在Facebook上分享我的网站的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆