简体   繁体   中英

Facebook “like” button which likes another page/URL

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>

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 .

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'

<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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM