我的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/en_UK/all.js');
});
</script>
</head>
<body>
<div class="fb-share-button" data-href="https://www.google.com/" data-layout="button_count"></div></p>
</body>
</html>
演示:
http://www.frostjedi.com/terra/scripts/demo/fb1.html
分享按钮没有出现,而idk为什么。有什么想法吗?
代码基于https://developers.facebook.com/docs/javascript/howto/jquery,除了没有设置API密钥(虽然我认为这不会产生影响)
答案 0 :(得分:0)
您使用的是Facebook脚本的错误网址。把它改成这个:
$.getScript('//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0');
<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/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-share-button" data-href="https://www.google.com/" data-layout="button_count"></div>