Skip to content

Instantly share code, notes, and snippets.

@robflaherty
Created June 8, 2010 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robflaherty/430376 to your computer and use it in GitHub Desktop.
Save robflaherty/430376 to your computer and use it in GitHub Desktop.
Dynamic URL Facebook Like Button
<!-- Like button placeholder -->
<div id="fbLikeBtn"></div>
<!-- Like button script -->
<script>
$(function(){
var fbUrl = encodeURIComponent(location.href),
fbIframe = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + fbUrl + '&amp;layout=standard&amp;show_faces=false&amp;width=300&amp;action=recommend&amp;font=arial&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:35px;" allowTransparency="true"></iframe>';
$("#fbLikeBtn").html(fbIframe);
});
</script>
@yairEO
Copy link

yairEO commented Apr 22, 2013

this is not dynamic at all...dynamic is when the url of the page changes visa history push state and THEN the "like" button is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment