Nowadays, you can see Facebook Like button or Recommend button on almost website/blogs. There are varying implementation ways to show this Facebook plugin on your website.
You can implement the Like/Recommend button with iframe, xfbml or html5 but with xfbml or html5, you need to load a JavaScript file from connect.facebook.net. There are also some main attributes that you need to get familiar with:
- width: the width of the button. Actually, the button is rendered in an iframe so it’s the width of the iframe.
- height: this attribute only works with iframe version.
- href: the URL to like or recommend
- action: the verb to display on the button, ‘like’ or ‘recommend’
- send: specifies whether to include a Send button with the Like or Recommend button
- layout: ‘standard’, ‘button_count’, ‘box_count’
When display the button on your website/blog, depend on the design or your need, the button could be a ‘Like’ or ‘Recommend’ button with its layout from very simple (just the button and count number) to quite complex (include Send button, faces and friend names).
Below is the list of situations that I often implement for the button. I’ll embed full html source code of a comprehensive demo page and a preview link right after that.
- 1. Simple Facebook Like button (fb:like, iframe and html5) – no text, no face
- 2. Simple Facebook Recommend button (fb:like, iframe and html5) – no text, no face
- 3. Simple Facebook Like button (fb:like, iframe and html5) with Send button – no text, no face
- 4. Simple Facebook Recommend button and Send button (fb:like, iframe and html5) – no text, no face
- 5. Like Button (fb:like, iframe and html5) with count number & friend name – no face
- 6. Recommend Button (fb:like, iframe and html5) with count number & friend name – no face
- 7. Recommend Button (fb:like, iframe and html5) with count number & friend name & face
- 8. Like Button and Send Button (fb:like, iframe and html5) with count number & friend name & face
- 9. Recommend Button and Send button (fb:like, iframe and html5) with count number & friend name & face
- 10. Recommend Button and Send button (fb:like, iframe and html5) with count number
HTML source code of the demo page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Preview Facebook Like Recommend</title> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> </head> <body> <h3>1. Simple Facebook Like button (fb:like, iframe and html5) - no text, no face</h3> <fb:like send="false" layout="button_count" width="90" font="arial" action="like" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=button_count&show_faces=false&width=450&action=like&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="button_count" data-send="false" data-width="450" data-show-faces="false" data-action="like"></div> <hr /> <h3>2. Simple Facebook Recommend button (fb:like, iframe and html5) - no text, no face</h3> <fb:like send="false" layout="button_count" width="90" font="arial" action="recommend" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=button_count&show_faces=false&width=450&action=recommend&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="button_count" data-send="false" data-width="450" data-show-faces="false" data-action="recommend"></div> <hr /> <h3>3. Simple Facebook Like button (fb:like, iframe and html5) with Send button - no text, no face</h3> <fb:like send="true" layout="button_count" width="90" font="arial" action="like" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=button_count&send=true&show_faces=false&width=450&action=like&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="button_count" data-send="true" data-width="450" data-show-faces="false" data-action="like"></div> <hr /> <h3>4. Simple Facebook Recommend button and Send button (fb:like, iframe and html5) - no text, no face</h3> <fb:like send="true" layout="button_count" width="90" font="arial" action="recommend" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=button_count&send=true&show_faces=false&width=450&action=recommend&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="button_count" data-send="true" data-width="450" data-show-faces="false" data-action="recommend"></div> <hr /> <h3>5. Like Button (fb:like, iframe and html5) with count number & friend name - no face</h3> <fb:like send="false" layout="standard" width="450" font="arial" show_faces="false" action="like" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=standard&show_faces=false&width=450&action=like&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="standard" data-send="false" data-width="450" data-show-faces="false" data-action="like"></div> <hr /> <h3>6. Recommend Button (fb:like, iframe and html5) with count number & friend name - no face</h3> <fb:like send="false" layout="standard" width="450" font="arial" show_faces="false" action="recommend" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=standard&show_faces=false&width=450&action=recommend&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="standard" data-send="false" data-width="450" data-show-faces="false" data-action="recommend"></div> <hr /> <h3>7. Recommend Button (fb:like, iframe and html5) with count number & friend name & face</h3> <fb:like send="false" layout="standard" width="450" font="arial" show_faces="true" action="recommend" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <hr /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=standard&show_faces=true&width=450&action=recommend&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:75px;" allowTransparency="true"></iframe> <hr /> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="standard" data-send="false" data-width="450" data-show-faces="true" data-action="recommend"></div> <hr /> <h3>8. Like Button and Send Button (fb:like, iframe and html5) with count number & friend name & face</h3> <fb:like send="true" layout="standard" width="450" font="arial" show_faces="true" action="like" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <hr /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=standard&send=true&show_faces=true&width=450&action=like&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:75px;" allowTransparency="true"></iframe> <hr /> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="standard" data-send="true" data-width="450" data-show-faces="true" data-action="like"></div> <hr /> <h3>9. Recommend Button and Send button (fb:like, iframe and html5) with count number & friend name & face</h3> <fb:like send="true" layout="standard" width="450" font="arial" show_faces="true" action="recommend" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <hr /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=standard&send=true&show_faces=true&width=450&action=recommend&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:75px;" allowTransparency="true"></iframe> <hr /> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="standard" data-send="true" data-width="450" data-show-faces="true" data-action="recommend"></div> <hr /> <h3>10. Recommend Button and Send button (fb:like, iframe and html5) with count number</h3> <fb:like send="true" layout="box_count" width="450" font="arial" show_faces="true" action="recommend" href="http://www.facebook.com/4.Rapid.Development"></fb:like><br /> <hr /> <iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/4.Rapid.Development&layout=box_count&send=true&show_faces=true&width=450&action=recommend&font&colorscheme=light&height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:75px;" allowTransparency="true"></iframe> <hr /> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/4.Rapid.Development" data-layout="box_count" data-send="true" data-width="450" data-show-faces="true" data-action="recommend"></div> <hr /> </body> </html> |

