javascript - Facebook login popup blocked in IE 9 - Stack Overflow

I have this button:<img src="staticimgfacebook_button.png" id="login-fb" oncli

I have this button:

<img src="static/img/facebook_button.png" id="login-fb" onclick="login();" />

I also have this script:

window.fbAsyncInit = function(){
    FB.init({
        appId : 'MY_APP_ID',
        status : true,
        cookie : true,
        xfbml : false
    });
};

Finally, I have this function:

function login()
{
    facebookPerms = [
        'user_photos', 'email', 'offline_access', 'user_relationships', 'read_stream',
        'user_about_me', 'user_birthday', 'user_education_history', //'publish_stream',
        'user_hometown', 'user_interests', 'user_location', 'user_likes',
        'user_religion_politics', 'user_activities', 'user_work_history'
    ];
    //Get the facebook login status
    FB.getLoginStatus(function(response) {
        if (response.session) {
            // logged in and connected user, someone you know
            ajaxLogin();
        } else {
            //Display the facebook login dialog
            FB.login(function(response) {
                if (response.authResponse) {
                    // user is logged in and granted some permissions.
                    // perms is a ma separated list of granted permissions
                    ajaxLogin();
                } else {
                    // user is not logged in, display the error dialog box
                    errorNotLogged();
                }
            }, {
                //Ask for permissions of Facebook
                scope: facebookPerms.join(',')
            });
        }
    });
}

I am following this Facebook rule:

Calling FB.login results in the JS SDK attempting to open a popup window. As such, this method should only be called after a user click event, otherwise the popup window will be blocked by most browsers.

And my website still gets its Facebook popup blocked in IE9. Any ideas how to solve this? Any ideas how other people do this without having their scripts being blocked?

I have this button:

<img src="static/img/facebook_button.png" id="login-fb" onclick="login();" />

I also have this script:

window.fbAsyncInit = function(){
    FB.init({
        appId : 'MY_APP_ID',
        status : true,
        cookie : true,
        xfbml : false
    });
};

Finally, I have this function:

function login()
{
    facebookPerms = [
        'user_photos', 'email', 'offline_access', 'user_relationships', 'read_stream',
        'user_about_me', 'user_birthday', 'user_education_history', //'publish_stream',
        'user_hometown', 'user_interests', 'user_location', 'user_likes',
        'user_religion_politics', 'user_activities', 'user_work_history'
    ];
    //Get the facebook login status
    FB.getLoginStatus(function(response) {
        if (response.session) {
            // logged in and connected user, someone you know
            ajaxLogin();
        } else {
            //Display the facebook login dialog
            FB.login(function(response) {
                if (response.authResponse) {
                    // user is logged in and granted some permissions.
                    // perms is a ma separated list of granted permissions
                    ajaxLogin();
                } else {
                    // user is not logged in, display the error dialog box
                    errorNotLogged();
                }
            }, {
                //Ask for permissions of Facebook
                scope: facebookPerms.join(',')
            });
        }
    });
}

I am following this Facebook rule:

Calling FB.login results in the JS SDK attempting to open a popup window. As such, this method should only be called after a user click event, otherwise the popup window will be blocked by most browsers.

And my website still gets its Facebook popup blocked in IE9. Any ideas how to solve this? Any ideas how other people do this without having their scripts being blocked?

Share Improve this question edited Jun 22, 2012 at 16:01 user2428118 8,1244 gold badges46 silver badges73 bronze badges asked Jun 22, 2012 at 12:34 Дамян СтанчевДамян Станчев 2,6745 gold badges31 silver badges53 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Try the following:

  • Fetch the user login status.
  • If the user is not logged in, show a login button.
  • On click call the FB.login function directly.

In your implementation FB.login is not called directly after a user interaction, but as a part of a callback function of FB.getLoginStatus. I guess this causes IE to block the popup.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745622242a4636591.html

相关推荐

  • javascript - Facebook login popup blocked in IE 9 - Stack Overflow

    I have this button:<img src="staticimgfacebook_button.png" id="login-fb" oncli

    22天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信