facebook javascript sdk fb_xd_fragment?

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:


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() {
       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;

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.

Solved with the iframe like button.

I used the approach within script to define the channelUrl to a page on my site, but I still got multiple hits back to that page.

After watching the resulting traffic with WireShark, I noticed they (Facebook) use a channelUrl for some of their own internal calls, also passing fb_xd_fragment – I instead used that URL for the channelUrl, redirecting it away from my site.

I have multiple Like buttons on my site using fbml instead of frames, and on IE7, I no longer get a hit back from Facebook with the fb_xd_fragment parameter.

Not sure if this is best practice but it seems to work.

I set this value for the channelUrl:


Hope this helps.

Although the answer above from github seems like an answer to another question, it does work well.
UPDATE: link is broken – try http://blog.colnect.com/2010/10/fbxdfragment-bug-workaround.html

affer few days research and expriment with all solution on internet at last i come up with combine of this

Change your head of your page:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/"  xmlns:fb="http://www.facebook.com/2008/fbml" lang="en-US">

here the cocde put this where you want likeit button is:

<div class="yourclass" style="z-index: 10;">
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js" ></script>
<script>FB.init({appId: '1234yourappidhere', status: true, cookie: true, xfbml: true});</script>
<fb:like href="http..yourencodedurlswillputhere" layout="button_count" width="150" action="recommend" colorscheme="light"></fb:like></div>
<script> document.getElementsByTagName('html')[0].style.display='block';</script>

credit wellcome : http://www.xaluan.com

The Channel hack did not work for me.
So I just added above all other content in my PHP file some code that 301 redirects to the URL without the fb_xd_fragment addition:

$url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

if (isset($_GET['fb_xd_fragment'])) {
$url = str_replace("?fb_xd_fragment=","",$url);
header( "HTTP/1.1 301 Moved Permanently" ); 
header("Location: {$url}");

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts