Add Facebook Share button to static HTML page
Is there any way to add a Facebook Share Button to a static HT开发者_如何学编程ML page? I've implemented a simple web site with no server side, just a bunch of html pages and I was abble to add a Like button because it is implemented with iFrame element. I have searched for a solution regarding the Share Button before posting here, but can't really find anything.
(Example of a share button can be seen on a youtube web site, on share section of each video.)
Any help is appreciated.
This should solve your problem: FB Share button/dialog documentation Genereally speaking you can use either normal HTML code and style it with CSS, or you can use Javascript.
Here is an example:
<a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fparse.com" target="_blank" rel="noopener">
<img class="YOUR_FB_CSS_STYLING_CLASS" src="img/YOUR_FB_ICON_IMAGE.png" width="22px" height="22px" alt="Share on Facebook">
</a>
Replace https%3A%2F%2Fparse.com, YOUR_FB_CSS_STYLING_CLASS and YOUR_FB_ICON_IMAGE.png with your own choices and you should be ok.
Note: For the sake of your users' security use the HTTPS link to FB, like in the a's href attribute.
You should be able to generate your own button code here: http://developers.facebook.com/docs/reference/plugins/like/
<a name='fb_share' type='button_count' href='http://www.facebook.com/sharer.php?appId={YOUR APP ID}&link=<?php the_permalink() ?>' rel='nofollow'>Share</a><script src='http://static.ak.fbcdn.net/connect.php/js/FB.Share' type='text/javascript'></script>
Replace <url>
with your own link
<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top left; }</style><a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share on Facebook</a>
<div class="fb_share">
<a name="fb_share" type="box_count" share_url="<?php the_permalink() ?>"
href="http://www.facebook.com/sharer.php">Partilhar</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> </div> <?php } }
add_action('thesis_hook_byline_item','fb_share');
In a very simple way, you can achieve this
<a href="https://www.facebook.com/share.php?u=your_page_link.com" target="_blank"> Facebook Share </a>
*replace your_page_link.com
with your desired URL or page link
Example
<a href="https://www.facebook.com/share.php?u=youtube.com" target="_blank"> Facebook Share </a>
精彩评论