Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- yang jelas daftar dulu biar dapat facebook application ID; kalo udah tambahkan namespace facebook untuk halaman html aplikasi anda:
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
- trus tambahin kode berikut untuk munculin tombol 'like' di tag <body> halaman aplikasi anda:
- <div id="fb-root"></div>
- <script type="text/javascript">
- <!--
- window.fbAsyncInit = function() {
- FB.init({appId: 'YOUR_FACEBOOK_APP_ID', status: true, cookie: true, xfbml: true});
- FB.Event.subscribe('edge.create', function(href, widget) {
- // tambahkan fungsi disini jika tombol 'like' ditekan
- // semisal munculkan link download, info tambahan atau apapun menurut kreasi anda
- alert('kamu udah like '+href);
- });
- };
- (function() {
- var e = document.createElement('script');
- e.type = 'text/javascript';
- e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
- e.async = true;
- document.getElementById('fb-root').appendChild(e);
- }());
- //-->
- </script>
- nah kalo pake prototype.js bisa pake kode ini:
- <script type="text/javascript" src="facebook.js"></script>
- <script type="text/javascript">
- <!--
- Event.observe(window, 'load', function() {
- new facebookLikeButtonClass('YOUR_FACEBOOK_APP_ID', 'en_US', function(href, widgetObject) {
- // tambahkan fungsi disini jika tombol 'like' ditekan
- // semisal munculkan link download, info tambahan atau apapun menurut kreasi anda
- alert('kamu udah like '+href);
- });
- });
- //-->
- </script>
- tentu mikir nih facebook.js itu isinya apa ya? ini isinya :
- var facebookLikeButtonClass = Class.create({
- initialize:function(appId, locale, callback)
- {
- window.fbAsyncInit = function() {
- if (typeof FB == 'undefined') {
- return;
- }
- FB.init({appId: appId, status: true, cookie: true, xfbml: true});
- FB.Event.subscribe('edge.create', function(href, widget) {
- if (callback != null) {
- callback(href, widget);
- }
- });
- };
- if ($('fb-root') == null) {
- var fbEl = new Element('div', {id: 'fb-root'});
- $(document.body).appendChild(fbEl);
- var sc = new Element('script', { type:'text/javascript', src:document.location.protocol + '//connect.facebook.net/'+locale+'/all.js', async:true });
- fbEl.appendChild(sc);
- window.fbInitDone = true;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement