Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why FB.getLoginStatus doesn't work in IE7?

I am using FB.getLoginStatus for an application in Facebook. This works fine in all the browsers, including IE8. But it doesn't work for IE7. My code is:

       FB.getLoginStatus(function(response) {              
           if (response.session) {
              alert("logout");
            }
            else{
                FB.Event.subscribe('auth.login', function(response) {
                    login();
                });
              alert("login");
            }
        });

Does anyone know why?

like image 511
novellino Avatar asked Jan 13 '11 11:01

novellino


1 Answers

According to the documentation at http://developers.facebook.com/docs/reference/javascript/fb.init/, the proper solution is to create a file on your web server (for instance channel.html) containing just:

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

And then specifying the absolute URL to your channel.html in your init options:

 <div id="fb-root"></div>
 <script src="http://connect.facebook.net/en_US/all.js"></script>
 <script>
   FB.init({
     appId  : 'YOUR APP ID',
     channelUrl  : 'http://example.com/channel.html'  // custom channel
   });
 </script>

For convenience in deployment, I use the following to calculate my channelUrl.

 var curLoc = window.location;
 curLoc.protocol + "//" + curLoc.hostname + ":" + curLoc.port + "/channel.html"
like image 167
DuckMaestro Avatar answered Sep 25 '22 20:09

DuckMaestro