facebook javascript sdk fb_xd_fragment? [英] facebook javascript sdk fb_xd_fragment?

查看:101
本文介绍了facebook javascript sdk fb_xd_fragment?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



什么是fb_xd_fragment?我看到它附加到我的网址的末尾,如 http://www.example.com/controller/ ?fb_xd_fragment ,这样会导致页面的一些令人厌恶的递归重新加载。

解决方案

找到一个解决方案,就像这里提到的一个自定义渠道网址,需要的是:



http://developers.facebook.com/docs/reference/javascript/FB.init



我所做的一切正在创建包含此单行的 channel.html 文件:

 < script src =http ://connect.facebook.net/en_US/all.js>< /脚本> 

然后我添加了channelUrl:line,最终结果如下:

 < div id =fb-root>< / div> <脚本> 
window.fbAsyncInit = function(){
FB.init({
appId:'MY APP ID',
status:true,//检查登录状态
cookie:true,//启用Cookie以允许服务器访问会话
xfbml:true,//解析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);
}() /脚本>

确保在xfbml之后添加一个逗号:如果是最后一行,则为true。我不熟悉Javascript,所以我不知道我是否充分利用这一点,但我知道它阻止了fb_xd_fragment问题,并允许在IE中的FB注释。据我所知,这是在线提供的唯一解决方案。欢迎进一步的调整。


I am using the facebook javascript sdk to embed a like button in my page.

What is fb_xd_fragment? I see it appends to the end of my url like http://www.example.com/controller/?fb_xd_fragment, and this is causing some nasty recursive reload of the page.

解决方案

After many weeks of trying to find a solution it looks like what is needed is a custom channel url as mentioned here:

http://developers.facebook.com/docs/reference/javascript/FB.init

All I did was create the channel.html file containing this single line:

<script src="http://connect.facebook.net/en_US/all.js"></script>

Then I added the channelUrl : line so the final result looks like this:

<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>

Make sure to add a comma after xfbml : true if it was your last line. I'm not familiar with Javascript so I don't know if I'm taking full advantage of this but I know it prevents the fb_xd_fragment issue and allows FB comments in IE. As far as I can tell, this is the ONLY solution available online. Any further tweaks are welcome.

这篇关于facebook javascript sdk fb_xd_fragment?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆