Created
May 30, 2011 18:31
-
-
Save vvo/999263 to your computer and use it in GitHub Desktop.
Async widgets
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
<!doctype html> | |
<html xmlns:fb="http://www.facebook.com/2011/fbml" xmlns:og="http://ogp.me/ns#"> | |
<!-- The xmlns:fb and xmlns:og are required for IE --> | |
<head> | |
<title>Loading widgets, async way</title> | |
</head> | |
<body> | |
<!-- FACEBOOK --> | |
<div id="fb-root"></div> | |
<!-- You could also use the iframe async loading technique, I will only discuss async xfbml way here. This is the official way to do it --> | |
<!-- use whatever facebook social plugin you want and add whatever xfbml attr you want | |
references, help : http://developers.facebook.com/docs/reference/javascript/ & http://developers.facebook.com/docs/plugins/ | |
my example is a simple facebook like button for the current page --> | |
<div class="likefacebook"><fb:like show_faces="false" width="260"></fb:like></div> | |
<script> | |
(function() { | |
// the channelUrl is mandatory but you should use it, more info : http://developers.facebook.com/docs/reference/javascript/FB.init/ | |
var channelUrl = "http://your.website.com/static/html/facebook/channel.html", | |
e; | |
window.fbAsyncInit = function() { | |
FB.init({xfbml: true, channelUrl : channelUrl}); | |
}; | |
e = document.createElement('script'); | |
e.async = true; | |
e.src = document.location.protocol + '//connect.facebook.net/fr_FR/all.js'; | |
document.getElementById('fb-root').appendChild(e); | |
}()); | |
</script> | |
<!-- /FACEBOOK --> | |
<!-- TWITTER share button --> | |
<!-- dunno if it's an official way but it works --> | |
<a | |
href="http://twitter.com/share" | |
class="twitter-share-button" | |
data-via="Promovac" | |
data-related="twitter,twitfond" | |
data-text=" Tunisie Séjour Tunis Hôtel Tunisia Lodge 4*" | |
data-count="none">Tweet</a> | |
<script> | |
(function() { | |
var e = document.createElement('script'); e.async = true; | |
e.src = document.location.protocol + '//platform.twitter.com/widgets.js'; | |
document.getElementsByTagName('head')[0].appendChild(e); | |
}()); | |
</script> | |
<!-- /TWITTER --> | |
<!-- FEEL FREE TO ADD YOURS ! --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment