Home » facebook » fb_xd_fragment, Fix for Blogger powered Blogs & Websites Newer Post

fb_xd_fragment, Fix for Blogger powered Blogs & Websites


While going through analytics last year I found a large number of urls with query string ?fb_xd_fragment=. While going to this link in a browser, I found, it displays the page for a while and then it goes white. It has been a big problem for a lot of websites, which uses FB Java SDK for like buttons. Someone, in facebook developers' forum recommended using the following code just before the </body> tag to solve this problem.

<!-- Correct fb_xd_fragment Bug Start -->

<script>

document.getElementsByTagName('html')[0].style.display='block';

</script>

<!-- Correct fb_xd_fragment Bug End -->

This fixed the problem for a long time, till it started once again, when I replaced the like button with, Like+Send button. A large number of pages, in analytics were showing the same query string with same problem. I was losing a big chunk of my traffic. I inspected once again if code installed has got corrupted, and hence pasted it there once again. It produced no impact on how the pages with that query string were served. Google has started indexing the pages with these query strings, and that is what has caused the problem. A blogger has suggested the following fix for this problem, which seems to work in most of the cases.

1/ Change your FB.init to the following

FB.init({appId: appId, status: true, cookie: true, xfbml: true, channelUrl: 'http://example.com/channel.html'});

// ^ channel URL above used to workaround fb_xd_fragment bug

2/ Create the static file for http://example.com/channel.html with the following content:

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

However, a blogspost blog cannot host a .js file. You need to host it on some other website. The solution is not the best for a blogspot blogger.

Fortunately, a member of Facebook Developer forum has given his own script and it works perfectly for blogger. You just need to paste it after opening <body> tag.

<script>

if(window.document.location.href.match('fb_xd_fragment')!=null)

{

var reg=/\?/

window.document.location.href.match('fb_xd_fragment');

var start=window.document.location.href.search(reg)

window.location=window.document.location.href.substring(0,start);

}

</script>

Some of the templates does not have <body> tag instead a variant is available, you just search for <body, and at the end of this tag paste the code there. It stops the problem immediately.
Also Read:
  1. 10 important things to do immediately after starting a BlogSpot blog
  2. 10 Ways to Quickly reduce the Bounce Rate on Landing Page
  3. Facebook Share - Fshare Workaround for Blogger

5 comments :

Javelot Salim said...

thank you men visit :
                                    http://www.allomart.com

Marathon Telecom said...

Great to know the -- in depth from this blog.This will really help for my forward steps to be taken.

machine to machine news said...

thanks for posting this, was really useful and interesting to me
 

Grathem said...

>>>Some of the templates does not have tag instead a variant
is available, you just search for <body, and at the end of this tag
paste the code there. It stops the problem immediately.
Here it is what i couldn't get the clue. Fixed and working as it should be!

ramesh said...

Many new templates don't have the conventional body tag. So search for what is in the article i.e., w/o closing tag.

Thanks for Reading Netargument. You may also Say Something about Yourself,HERE! http://www.netargument.com/p/about-you.html