2

这里是我的代码的FB.login的权限对话框stucks在IE9

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
<head> 
<title></title> 
</head> 
<body> 
<div id="fb-root"> 
</div> 
<script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'XXXXXX', // App ID 
      channelUrl: '//localhost:63651/channel.htm', // Channel File 
      status: true, // check login status 
      cookie: true, // enable cookies to allow the server to access the session 
      xfbml: true, // parse XFBML 
      oauth: true 
     }); 

     // Additional initialization code here 
    }; 

    // Load the SDK Asynchronously 
    (function (d) { 
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
     if (d.getElementById(id)) { return; } 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     ref.parentNode.insertBefore(js, ref); 
    } (document)); 
</script> 
<input type="button" value="login" id="login" onclick="return login();" /> 
<script> 

    function login() { 

     FB.login(function (response) { 
      if (response.authResponse) { 
       console.log('Welcome! Fetching your information.... '); 
       FB.api('/me', function (response) { 
        alert(response); 
        console.log('Good to see you, ' + response.name + '.'); 
       }); 
      } else { 
       console.log('User cancelled login or did not fully authorize.'); 
      } 
     }, { scope: 'email,user_work_history,publish_stream' }); 



    } 
</script> 
</body> 
</html> 

所以我的问题是,Facebook的在IE9的权限对话框stucks见下文facebook error
铬它的工作原理,但与此错误

Unsafe JavaScript attempt to access frame with URL https://www.facebook.com/dialog/permissions.request from frame with URL http://localhost:63651/plans/. Domains, protocols and ports must match. 

我已经使用了与fb文档中描述的相同的代码。

有帮助吗?
如果需要,我可以提供更多细节。我没有任何选择。
谢谢

+0

'的http://本地主机:63651 /计划/'似乎对我来说,你试图在localhost中测试它..在我的情况下FB连接只适用于preprod或prod服务器,我必须配置我的FB应用程序与这些域.. – pleasedontbelong

+0

谢谢@pleasedontbelong。这工作正常。 – Nnp

回答

1

尝试将channelURL文件放在internet(无本地主机url)和默认http端口(80)上。 的问题可能是,它并不能识别不同的端口进行连接,或者说,它希望它公布在互联网上(不是localhost)

FB.init({ 
     appId: 'XXXXXX', // App ID 
     channelUrl: '//your-website.com/channel.htm', // Channel File 
     status: true, // check login status 
     cookie: true, // enable cookies to allow the server to access the session 
     xfbml: true, // parse XFBML 
     oauth: true 
    }); 
+0

谢谢@Luca。这工作正常。 – Nnp

+0

不客气@Nnp –