pixelhandler

Pushin' & pullin' pixels on the net

Insert Facebook Like Button With Current Page’s URL

If you are not using the full facebook .js api then here is a lightweight script to insert a facebook like button into a div (with id, ‘social’ ) [this example is using prototype].
facebook like button (insert_facebook_like.js) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// '$' is prototype library
(function(){
// use location for facebook like button
var $pg = {
url : unescape(document.location.href),
social : $('social') // id to place like button in
}
$pg.fb = '<div id="facebook"><iframe';
$pg.fb += ' src="http://www.facebook.com/plugins/like.php?href=';
$pg.fb += $page.url;
$pg.fb += '&layout=button_count&show_faces=true&';
$pg.fb += 'width=90&action=like&colorscheme=light&amp';
$pg.fb += 'height=30" scrolling="no" frameborder="0" style=';
$pg.fb += '"border:none; overflow:hidden; width:90px; ';
$pg.fb += 'height:30px;" allowTransparency="true">';
$pg.fb += '</iframe></div>';
if ($pg.social) {
$pg.social.insert({ 'bottom' : $pg.fb });
};
})($);
<div id="social"></div>

Comments