问题
I have applied the Facebook like button on a page where I am displaying all the post from my WordPress admin. I applied the Facebook like button code, and it is working fine here, but when user clicks on the post, that post is getting open in FancyBox where I am applying the Facebook like button, but the Facebook like button is not getting created there. How can I do this?
This is the code I am using to create the Facebook like button at both places:
<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&appId=145332828885141";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like"
data-href="https://www.facebook.com/pages/PHPsyms/130379690383205"
data-send="false"
data-layout="button_count"
data-width="450"
data-show-faces="false"></div>
回答1:
It will work in FancyBox:
<iframe
src="http://www.facebook.com/plugins/like.php?href=URL_HERE%2F&layout=button_count&show-faces=false&width=450&action=like&font=arial&colorscheme=light"
scrolling="no"
frameborder="0"
allowTransparency="true"
style="border:none;
overflow:hidden;
width:110px;
height:px">
</iframe>
来源:https://stackoverflow.com/questions/10250402/facebook-like-button-not-displaying-in-fancybox