简体   繁体   中英

Facebook infinite loop, setTimeout not helping =(

I have a loop on my facebook when using ie and firefox ( Facebook Javascript SDK window location reload not working on Firefox ) because of the:

FB.Event.suscribe('auth.login',function(response){
    location.reload(true);
});

I tryied with:

FB.Event.suscribe('auth.login',function(response){
    window.setTimeout('location.reload(true)',0);
});

But it keeps doing the loop.

Additional information: I'm only using html,javascript and jquery not using php, asp, aspx, ruby, nothing else than that.

Change to:

FB.Event.suscribe('auth.login',function(response){
   window.setTimeout(function () {
       location.reload(true);
   },0);
});

You shouldn't call reload if user already connected

FB.getLoginStatus(function(response) {
    var reload = function(){location.reload(true);};
    if(response.status !== 'connected'){
        FB.Event.subcribe('auth.login',function(response){
            setTimeout(reload,0);
        });
    }else {
        FB.Event.subcribe('auth.logout',function(response){
            setTimeout(reload,0);
        });
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM