Please wait for 15 seconds...

Wednesday 9 April 2014



Many times it happen when you open a webpage in your browser whole page loads just fine but not facebook like button, facebook page feed, twitter share button, linkedin share button,  google plus one button etc.

It is because of browser addons/plugins, like avast online security, Adblock plus etc., block them.
Well it is no problem for visitors but webmaster do not like it much. Here are few solutions that find out if social plugins like Facebook, Twitter, Linkedin have been blocked by browser 's add-on/plugin.

Suppose If facebook SDK did not load then replace blank spots(where facebook buttons/content suppose to display) with some useful content or you can do other cool stuff, so let's get start it.


Insert jQuery API


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

Facebook

Detect if social SDK/content did not load

Copy and paste below code just before </head> tag.

Facebook Script


<script type="text/javascript">
$(window).load(function(){
if(typeof window.FB == 'undefined'){
alert('Facebook SDK is unable to load, display some alternative content for visitor');
}
else{
alert('Facebook is working just fine');
}
});
</script>

Twitter Script


<script type="text/javascript">
$(window).load(function(){
if(typeof window.__twttrlr == 'undefined'){
alert('Twitter SDK is unable to load, display some alternative contect for visitor');
}
else{
alert('Twitter is working just fine');
}
});
</script>

Linkedin Script


<script type="text/javascript">
$(window).load(function(){
if(typeof window.IN == 'undefined'){
alert('Linkedin SDK is unable to load, display some alternative contect for visitor');
}
else{
alert('Linkedin is working just fine');
}
});
</script>

You can also detect google plus, pinterest and other social network JS library on your website using similar method.

Posted by Atul

0 comments:

Post a Comment

Techsirius on Facebook