I just want a basic facebook like button on my site. I follow the instructions per facebooks site (http://developers.facebook.com/docs/reference/plugins/like/). I tried the HTML5
, XFBML
, and iFrame
ways, no joy on either. So I thought maybe it's something with my site interfering. So I created a bare-bones html page like below and it still gives me the FB.getLoginStatus()
called before calling FB.init()
error.
<html>
<body>
<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/[mypage]" data-send="false" data-width="450" data-show-faces="false"></div>
</body>
</html>
UPDATE: I removed all that stuff above went back to the iFrame
only method and it works, but only in Firefox. Chrome and IE9 I still get nothing but no errors reported. Why is this line below only working in FireFox (obviously the [myPage] part is swapped out)?
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2F[myPage]&send=false&layout=standard&width=450&show_faces=false&action=like&colorscheme=light&font&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…