Facebook “like” button which likes another page/URL

北城余情 提交于 2019-12-07 12:04:00

问题


I have a list of links and on each individual page there's a "like" button to "like" that page. But I want a "like" button next to each link in the list which will like the URL of the link next to it (just like it would if you clicked on the link and then the "like" button).

How do I do this?

To create the button on each individual page I use the following code:

<script>
window.fbAsyncInit = function()
{
     FB.init({appId: '*****', status: true, cookie: true, xfbml: true});
};
</script>

<div class="share_button btn_fb">
<fb:like layout="button_count" font="tahoma"></fb:like>
</div>

回答1:


You can use the iframe version of the Like Button, rather than FBML. The iframe requires that you pass the url as part of the query string.

You can generate the iframe code here.




回答2:


Try the following:

<fb:like layout="button_count" href="http://yourlink.com" font="tahoma"></fb:like>

Where the href attribute is the URL you want the person to 'like'




回答3:


<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="[put the url here]" send="true" width="450" show_faces="true" font=""></fb:like>

Just replace the [put the url here] with the url you want to like and then paste the full code to the place where you want the like button.




回答4:


You can always just go to the Facebook Developers page here:

http://developers.facebook.com/docs/reference/plugins/like/

and it will generate the code for you, and you can just copy it into your site. I just re-verified it. It works nicely.

This will generate the code(or something similar) that @Coding-Freak wrote.



来源:https://stackoverflow.com/questions/6203164/facebook-like-button-which-likes-another-page-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!