0
window.fbAsyncInit = function () {
    FB.init({
        appId: '#',
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    })
    FB.getLoginStatus(function (response) {
        if(response.status === 'connected') {
            var uid = response.authResponse.userID;
            alert(uid);
            FB.api('/' + uid, {
                fields: 'name,email,id,picture'
            }, function (result) {
                //Code
            })
        }
    })
    FB.Event.subscribe('auth.login', function (response) {
        // do something with response
        login();
    });
    FB.Event.subscribe('auth.logout', function (response) {
        logout();
    });
    FB.getLoginStatus(function (response) {
        if(response.session) {
            // logged in and connected user, someone you know
            login();
        }
    });
};

function login() {
    FB.getLoginStatus(function (response) {
        if(response.status === 'connected') {
            var uid = response.authResponse.userID;
            // alert(uid);
            FB.api('/' + uid, {
                fields: 'name,email,id,picture'
            }, function (result) {
                //code
            })
        }
    })
}

function logout() {
    //code
}
(function () {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol + '//connect.facebook.net/en_GB/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
}());

I use the <div class="fb-login-button">Sign in with Facebook</div> for the login button to appear.

I have put this script in a JS file and i'm using it on my JSP.

I get a login authentication screen in firefox and chrome, but somehow the button doesn't show in IE 7,8,9

Bojangles
  • 99,427
  • 50
  • 170
  • 208
  • @Jam what beautifier did you use? – Martin. Mar 09 '12 at 19:51
  • @Martin. [jsbeautifier.org](http://jsbeautifier.org/) – Bojangles Mar 09 '12 at 19:54
  • @Jam me too, but for some reason, it did keep 8 spaces at the start – Martin. Mar 09 '12 at 19:55
  • @Martin it will indent the code relative to how far the first line is indented, so for a whole indent of four spaces, you just lrepend four spaces to the beginning of the first line. – Bojangles Mar 09 '12 at 23:21
  • See this links: [link1](http://stackoverflow.com/questions/2957914/facebook-like-button-showing-in-firefox-but-not-showing-in-ie) [link2](http://stackoverflow.com/questions/4116711/fblogin-button-problems-with-ie8-internet-explorer-only) – Somnath Muluk Mar 10 '12 at 05:29

1 Answers1

0

Idk if this is your problem or not, but you might try adding:

<html xmlns:fb="http://www.facebook.com/2008/fbml">

To your html document

An explanation here:

http://www.zolton.org/2011/04/facebook-fbml-tags-fail-to-load-in-ie/

Mikey G
  • 3,473
  • 1
  • 22
  • 27