我想從Facebook JS SDK的文檔運行第一個示例。我創建了一個新應用程序,創建了一個名爲「facebookTest.html」的空白文檔,粘貼了示例中的代碼,並插入了新應用程序的應用程序ID。代碼如下:使用Facebook的示例代碼「無法加載資源」
<html>
<head>
<title>Login with facebook</title>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'my app ID', // App ID from the App Dashboard
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
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 = document.location.protocol+"//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
當網頁加載完畢後,這個Javascript控制檯,我得到了以下錯誤消息上:
Failed to load resource
我在做什麼錯?
編輯:當我"//connect.facebook.net/..."
前加document.location.protocol
,如建議here,屏幕一直空白,並在控制檯顯示以下內容:
GET file://connect.facebook.net/en_US/all.js
是:所有這些代碼是應該做的?還是它仍然失敗?
檢查您的廣告攔截! :) – FooBar