Facebook JS SDK のドキュメントから最初の例を実行しようとしています。新しいアプリを作成し、「facebookTest.html」という空のドキュメントを作成し、例のコードを貼り付けて、新しいアプリのアプリ ID をプラグインしました。次のようにコードします。
<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
私は何を間違っていますか?
編集:ここで提案されているように、document.location.protocol
の前に追加すると、画面は空白のままになり、コンソールには次のように表示されます。"//connect.facebook.net/..."
GET file://connect.facebook.net/en_US/all.js
このコードが行うべきことはそれだけですか? それともまだ失敗していますか?