2014-03-12 66 views
16

我目前正在製作Facebook JavaScript應用程序。因此我真的只是複製粘貼出來的文檔到我的網頁,我不斷收到在控制檯以下錯誤:Facebook Uncaught安全性錯誤

Uncaught SecurityError: Blocked a frame with origin "http://static.ak.facebook.com" from accessing a frame with origin "http://localhost:8080". Protocols, domains, and ports must match. VM2813:1 
Uncaught SecurityError: Blocked a frame with origin "https://s-static.ak.facebook.com" from accessing a frame with origin "http://localhost:8080". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match. 
VM2817:1 
Uncaught SecurityError: Blocked a frame with origin "http://static.ak.facebook.com" from accessing a frame with origin "http://localhost:8080". Protocols, domains, and ports must match. 

因此然後,我添加http://localhost:8080到我的Facebook應用程序頁面,但我仍然會有同樣的錯誤。 enter image description here

這裏是我使用的代碼:

<body> 

    <div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId  : '644205045632878', 
      status  : true, 
      xfbml  : true 
     }); 
     }; 

     (function(d, s, id){ 
     var js, fjs = d.getElementsByTagName(s)[0]; 
     if (d.getElementById(id)) {return;} 
     js = d.createElement(s); js.id = id; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     fjs.parentNode.insertBefore(js, fjs); 
     }(document, 'script', 'facebook-jssdk')); 
    </script> 
</body> 

請某人能解釋什麼是錯在這裏。這是我第一次這樣做......

+0

我猜測您的用戶設置中啓用了「安全瀏覽」,因此您的服務器還需要能夠通過HTTPS進行響應... – Tobi

回答

60

如果您正在測試安裝了Ripple仿真器的Chrome當您看到這些錯誤消息時,請嘗試禁用Ripple(來自設置,而不僅僅是針對特定頁面)。很明顯,即使Ripple沒有爲特定頁面啓用,它也會攔截響應並阻礙。

我在安裝和啓用Ripple Emulator(Beta)0.9.15擴展的Windows 7 Pro 64位上使用Chrome版本34.0.1847.131觀察到此情況。

+0

T漢克斯!當我擺脫它時,錯誤消失了。無論如何,這對我來說永遠沒有任何用處。 – Emeka

+0

+1做得非常好! – saj

+6

如果只有我可以upvote 100倍 – Atrix1987