我已使用iframe代码将FB设置为按钮...
以下是Like Button的代码:
<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fmadamebridal.com%2Fdev%2Fcheckout%2Fonepage%2F&send=false&layout=standard&width=450&show_faces=true&font&colorscheme=light&action=like&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
我正在使用此代码捕获FB类似事件......
以下是代码:
window.fbAsyncInit = function() {
(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'));
// Additional initialization code here
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked THISSS Yeaa');
}
);
};
但......它没有用。
答案 0 :(得分:2)
你的问题根本不清楚,当你去看医生时你不说,我感到疼痛,并希望他能治好你。你正在加载javascript sdk吗?
此代码应该适合您,除非您有其他脚本触发错误并阻止facebook sdk正常工作。
将此代码放在您的<body>
代码
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
FB.Event.subscribe('edge.create', function(response) {alert('You liked THISSS Yeaa'); });
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>