Multiple fbAsyncInit's?

非 Y 不嫁゛ 提交于 2019-12-03 08:54:11

You can use this instead to check if you already have a fbAsyncInit and chain it toghether in that case:

var oldCB = window.fbAsyncInit;
window.fbAsyncInit = function(){
    if(typeof oldCB === 'function'){
        oldCB();
    }
    //Do Something else here
 };

Sometimes the facebook api can call fbAsyncInit before your second fbAsyncInit has even started. This will fix that case:

        if (window.fbAsyncInit.hasRun === true) {
            setup(); // do something
        } else {
            var oldCB = window.fbAsyncInit;
            window.fbAsyncInit = function () {
                if (typeof oldCB === 'function') {
                    oldCB();
                }
                setup(); // do something
            };
        }

there is a "static" property in fbAsyncInit

Try below

if (window.fbAsyncInit && window.fbAsyncInit.hasRun) {
    // do sth
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!