以iframe方式嵌入Facebook的Like Button(讚)

今天學弟問我怎麼嵌入Facebook的Like Button(讚),才發現現在Facebook沒有再提供iframe方式嵌入了,趕緊從以前的作品中挖出來備份一下。

<iframe src="http://www.facebook.com/plugins/like.php?href=你的網址" scrolling="No" frameborder="0" style="border:none; overflow:hidden; width:450px;" allowtransparency="true"></iframe>

我覺得這個方法是最方便的,比起現在提供的HTML5之類的都還要方便!

如果是blogger要用的話,請貼上這串:
<iframe allowtransparency='true' expr:src='&quot;http://www.facebook.com/plugins/like.php?href=&quot; + data:post.url + &quot;&amp;send=true&amp;layout=standard&amp;show_faces=true&amp;width=600&amp;action=like&amp;colorscheme=light&quot;' frameborder='0' scrolling='no' style='border: none; height: 65px; overflow: hidden; width: 400px;'/>


以下是解釋:

expr:src='&quot;http://www.facebook.com/plugins/like.php?href=&quot; + data:post.url + &quot;
&amp;
//這段就是讓facebook判斷blogger每篇文章網址的語法

send=false&amp;
//這段是讚旁邊要不要顯示分享,false改成true的話就會顯示

layout=button_count&amp;
//這是fb讚的造型,其他造型還有standard、box_count、button共四種造型

show_faces=true&amp;
//要不要顯示讚的人的臉,只有true才會顯示

width=90&amp;
//寬度

action=like&amp;
//顯示讚,如果想顯示推薦就將like改成recommend

colorscheme=light&quot;
//如果你的網站是深色系背景的話才改成dark


資料參考自:https://developers.facebook.com/docs/plugins/like-button/