Jam*_*Lin 23 javascript sdk facebook
我正在使用facebook javascript sdk在我的页面中嵌入一个类似的按钮.
什么是fb_xd_fragment?我看到它附加到我的URL的末尾,如http://www.example.com/controller/?fb_xd_fragment,这导致页面的一些讨厌的递归重新加载.
小智 23
经过数周试图找到解决方案后,看起来需要的是这里提到的自定义渠道网址:
http://developers.facebook.com/docs/reference/javascript/FB.init
我所做的只是创建包含这一行的channel.html文件:
<script src="http://connect.facebook.net/en_US/all.js"></script>
Run Code Online (Sandbox Code Playgroud)
然后我添加了channelUrl:行,所以最终结果如下所示:
<div id="fb-root"></div> <script>
window.fbAsyncInit = function() {
FB.init({
appId : 'MY APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://www.example.com/channel.html' // custom channel
}); };
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());</script>
Run Code Online (Sandbox Code Playgroud)
确保在xfbml之后添加逗号:如果它是你的最后一行,则为true.我不熟悉Javascript所以我不知道我是否正在充分利用这个,但我知道它可以防止fb_xd_fragment问题,并允许在IE中进行FB注释.据我所知,这是在线提供的唯一解决方案.欢迎进一步调整.