Created
November 6, 2013 12:27
-
-
Save Nowalon/7335271 to your computer and use it in GitHub Desktop.
From https://developers.facebook.com/docs/reference/javascript/
add a <script type="text/javascript" src="script.js"></script>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
// init the FB JS SDK | |
FB.init({ | |
appId : 'YOUR_APP_ID', // App ID from the app dashboard | |
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms | |
status : true, // Check Facebook Login status | |
xfbml : true // Look for social plugins on the page | |
}); | |
// Additional initialization code such as adding Event Listeners goes here | |
}; | |
// Load the SDK asynchronously | |
(function(){ | |
// If we've already installed the SDK, we're done | |
if (document.getElementById('facebook-jssdk')) {return;} | |
// Get the first script element, which we'll use to find the parent node | |
var firstScriptElement = document.getElementsByTagName('script')[0]; | |
// Create a new script element and set its id | |
var facebookJS = document.createElement('script'); | |
facebookJS.id = 'facebook-jssdk'; | |
// Set the new script's source to the source of the Facebook JS SDK | |
facebookJS.src = '//connect.facebook.net/en_US/all.js'; | |
// Insert the Facebook JS SDK into the DOM | |
firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement); | |
}()); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment