Skip to content

Instantly share code, notes, and snippets.

@basuke
Created January 20, 2011 01:28
Show Gist options
  • Save basuke/787244 to your computer and use it in GitHub Desktop.
Save basuke/787244 to your computer and use it in GitHub Desktop.
How to load Facebook connect script localized for the page viewer.
<div id="fb-root">
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: '123456789xxxxxx',
status: true,
cookie: true,
xfbml: true
});
};
(function() {
var locale;
try {
locale = window.navigator.language.split('-');
locale = locale[0].toLowerCase() + '_' + locale[1].toUpperCase();
} catch (e) {
locale = 'en_US';
}
document.writeln('<script type="text/javascript" src="http://connect.facebook.net/' + locale + '/all.js" async><\/script>');
})();
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment