1
我試圖讓這個事件FB訂閱觸發的事件(警報(「你好」)),但它似乎沒有工作,雖然:點擊Facebook按鈕之後沒有觸發事件?
<!doctype html>
<html lang="en" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta charset="utf-8">
<title>Facebook Like Button</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'myappid', status: true, cookie: true, xfbml: true });
targetUrl="http://www.goal.com";
FB.Event.subscribe("xfbml.render", function() {
console.log('xfbml.render');
FB.Event.subscribe("edge.create", function (targetUrl) {
console.log('edge.create');
alert('hi');
});
FB.Event.subscribe("edge.remove", function (targetUrl) {
console.log('edge.remove');
});
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<fb:like></fb:like>
</body>
</html>
我會嘗試使用edge.create事件OUTSIDE的xfbml.render事件回調函數:__) – Rufinus
沒有幫助:( – user603007