2011-11-22 2 views
3

Facebook에서 요청 대화 상자를 만들었고 Firefox와 Chrome에서 잘 작동하지만 IE8에서는 오류 : FB is undefined이 표시됩니다. 친절하게도 내가 사용한 코드를 찾으십시오.IE8의 오류

<html xmlns=="http://www.w3.org/1999/xhtml" 
    xmlns:fb="https://www.facebook.com/2008/fbml"> 
    <head> 
    <title>Request Tester C</title> 

     </head> 

    <body> 
<div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 

<p> 
</p> 
<script> 

    FB.init({ 
    appId : 'XXXXXXXXXXXXXXXXXXXXX', 
    status : true, 
    cookie : true, 
    oauth: true 
    }); 


    function sendRequestViaMultiFriendSelector() { 
    FB.ui({method: 'apprequests', 
     message: 'My Great Request' 
    }, requestCallback); 
    } 

    function requestCallback(response) { 
    // Handle callback here 
      window.location.href = "test.php"; 

    } 
      sendRequestViaMultiFriendSelector();  
    </script> 


</body> 
</html> 

답변

1

문제는 Facebook 기능을 사용하려고 할 때까지로드가 완료되지 않았기 때문입니다. Facebook에 따르면 :

Almost all Facebook Connect's JS APIs are loaded asynchronously after calling FB.init(). Because of the asynchrous nature, the JS APIs are not necessaryly available immediately after making these calls. You should use FB.ensureInit or FB.Bootstrap.requireFeatures to ensure the JS APIs are loaded before using them.

We have a wiki documentation that describes this in more detail. However, we just found out that some Connect apps were calling Connect JS API such as FB.Connect.* and FB.Facebook.* immedidately after calling FB.init. This approach would cause intermittent failures because the functions may not be loaded yet.

설명서는 매우 좋으며 (100 % 완전하지 않음) 유용하며 유용 할 것입니다. 지금은 다음과 같이 코드를 래핑하는 것으로 충분합니다.

function sendRequestViaMultiFriendSelector() { 
    FB.ui({method: 'apprequests', 
    message: 'My Great Request' 
    }, requestCallback); 
} 

function requestCallback(response) { 
    // Handle callback here 
    window.location.href = "test.php"; 
} 

FB_RequireFeatures(["Connect"], function() { 
    FB.init({ 
    appId : 'XXXXXXXXXXXXXXXXXXXXX', 
    status : true, 
    cookie : true, 
    oauth: true 
    }); 
    sendRequestViaMultiFriendSelector(); 
}); 
+0

당신의 도움에 대한 앤드류 감사, 나는 위의 코드를 사용하지만, 나는 다음과 같은 오류 얻을 : 오류 : FB_RequireFeatures 소스 파일을 정의되지 않습니다 : 라인 XXXXXXXXXXXXXXXX : 23 개 어떤 아이디어가 만족을 가능하게하여 – user1022745

+0

당신이 있습니까 어떤 종류의 광고 차단 소프트웨어? –

0

ie8을 사용할 때 똑같은 문제가 발생했습니다.

빠른 수정이 가능 HTTP://connect.facebook.net/en_US/all.js 를 사용하는 대신 SSL가는 몇 가지 이유를 들어 HTTPS://connect.facebook.net/en_US/all.js

문제가 해결 사용하지 통해 달성 될 수있다.