Hi I have setup connect with Facebook button for my forum, http://www.afghanistanforums.com but some users can connect with it and some of them can't. I have checked FireFox error console and it says Error: FB is not defined Source File: http://www.afghanistanforums.com/fbc/fbconnect.js Line: 3 Here is the code: // check wheather there logged into fb and have permissions get errors otherwise if logged in got to connect and register them page else display login form for facebook function fbLogin() { [B](This is line 3: )[/B] FB.Connect.requireSession(function() { FB.Connect.showPermissionDialog('email,status_update,read_stream,publish_stream', function() { document.location = smf_scripturl + '?action=facebook;sa=connect;step'; }); }); } Code (markup): And Error: FB is not defined Source File: http://www.afghanistanforums.com/index.php Line: 1077 <script type="text/javascript"> [B](Line 1077 )[/B] FB.init("54b596dea11e0b605286d36df17374ab", "http://www.afghanistanforums.com/fbc/xd_receiver.htm", {"doNotUseCachedConnectState":true }); function doLoggedOutFacebookUser(){ FB.Connect.logout(function(){location.href = "http://www.afghanistanforums.com/index.php?action=logout;sesc=ab2e5be78e1b69ebdce6fbc844edba53";}); } </script> Code (markup):
Searching for that error message turns up some interesting things. It seems that calls are being made before the script has fully loaded. It might be due to a loading delay, which some people have fixed by adding a short timeout. The script might be blocked by the Noscript plugin, so check if it works with Firefox in safe mode.
It is not working in safemode. Here is the complete code: // check wheather there logged into fb and have permissions get errors otherwise if logged in got to connect and register them page else display login form for facebook function fbLogin() { FB.Connect.requireSession(function() { FB.Connect.showPermissionDialog('email,status_update,read_stream,publish_stream', function() { document.location = smf_scripturl + '?action=facebook;sa=connect;step'; }); }); } // check wheather there logged into fb and have permissions get errors otherwise if logged in got to facebook page else display login form for facebook function fbLogincheck() { FB.Connect.requireSession(function() { FB.Connect.showPermissionDialog('email,status_update,read_stream,publish_stream', function() { document.location = smf_scripturl + '?action=facebook'; }); }); } // check wheather there logged into fb and have permissions get errors otherwise if logged in got to sync page else display login form for facebook function fbLoginsync() { FB.Connect.requireSession(function() { FB.Connect.showPermissionDialog('email,status_update,read_stream,publish_stream', function() { document.location = smf_scripturl + '?action=facebook;sa=sync'; }); }); } // actuly post to facebook function callPublish(msg, attachment, action_link) { FB.ensureInit(function () { FB.Connect.streamPublish('', attachment, action_link); }); } //gets the fabook comment box has tobe done via js to get valid xhtml fb tags are not valid xhtml using js gets aroumd it function Get_comments(){ document.getElementById("comments").innerHTML = "<fb:comments xid=" + mod_settings_fb_com_xid + " numposts=" + mod_settings_fb_com_show + "></fb:comments>"; } //gets the fabook fan box has tobe done via js to get valid xhtml fb tags are not valid xhtml using js gets aroumd it function Get_fanbox(){ document.getElementById("fans").innerHTML = "<fb:fan profile_id=" + mod_settings_fb_app_pageid + " stream=" + mod_settings_fb_app_stream + " connections=" + mod_settings_fb_app_connection + " width=" + mod_settings_fb_app_width + "></fb:fan>"; } //gets the facebook share button function Get_share(){ document.getElementById("share").innerHTML = "<span id='facebook'><a name='fb_share' type='button' share_url=" + smf_scripturl + "?topic=" + mod_settings_fb_share + "></a></span>"; } Code (markup):