You can do this using the asynchronous Javascript SDK provided by facebook
Look at the following code
Initializing the FB Javascript SDK
<div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: 'YOUR APP ID', status: true, cookie: true, xfbml: true}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script>
Note. Remember to replace your APP ID with your facebook AppId. If you donโt have a facebook AppId and donโt know how to create it, check this out
Add jQuery library, I would prefer Google Library
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
Add a sharing dialog (you can customize this dialog by setting options
<script type="text/javascript"> $(document).ready(function(){ $('#share_button').click(function(e){ e.preventDefault(); FB.ui( { method: 'feed', name: 'This is the content of the "name" field.', link: 'http://www.groupstudy.in/articlePost.php?id=A_111213073144', picture: 'http://www.groupstudy.in/img/logo3.jpeg', caption: 'Top 3 reasons why you should care about your finance', description: "What happens when you don't take care of your finances? Just look at our country -- you spend irresponsibly, get in debt up to your eyeballs, and stress about how you're going to make ends meet. The difference is that you don't have a glut of taxpayersโฆ", message: "" }); }); }); </script>
Now finally add the image button
<img src = "share_button.png" id = "share_button">
A more detailed view of the information. please click here
Virat Gaywala May 23 '14 at 6:35 a.m. 2014-05-23 06:35
source share