Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Facebook Share button to static HTML page

Is there any way to add a Facebook Share Button to a static HTML 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.

like image 941
aumanets Avatar asked Mar 29 '11 20:03

aumanets


People also ask

Why doesn't my Facebook page have a share button?

Ok, so apparently FB has updated their privacy settings... For those of you seeing the "Share" option in your posts... That means that post is open to the public to see. If you have your profile settings set to "Friends", then no one will be able to share your posts.


1 Answers

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.

like image 116
PhobosK Avatar answered Sep 21 '22 07:09

PhobosK