Sun*_*ani 8 iframe facebook facebook-like
我不想使用xfbml.我需要像下面的按钮一样使用iframe.但那不是解雇edge.create.
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// initalize your Facebook App
FB.init({
appId : '113869198637480',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// subscribe to the event
FB.Event.subscribe('edge.create', function(response) {
alert('you liked this');
});
FB.Event.subscribe('edge.remove', function(response) {
alert('you unliked this');
});
</script>
<iframe id="test" src="http://www.facebook.com/plugins/like.php?
href=http://google.com/&
layout=button_count&
show_faces=false&
width=50&
action=like&
colorscheme=light&
height=21"
scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:50px;
height:21px;"
allowTransparency="true">
Run Code Online (Sandbox Code Playgroud)
这是完全可以预料的; javascript回调仅在使用社交插件的Javascript版本时可用,包括Like按钮.
这在Like Button文档中提到:
How do I know when a user clicks a Like button?
If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.
Run Code Online (Sandbox Code Playgroud)
当您将Like按钮直接包含为iFrame时,Facebook服务器上的事件无法传播回您的javascript代码 - 当使用XFBML版本的Like按钮时,Facebook Javascript SDK会处理此通信
| 归档时间: |
|
| 查看次数: |
3014 次 |
| 最近记录: |