How to add Facebook share button without app id ?

How to add Facebook share button without app id ?


Facebook share button

Facebook share button is very much effective for every webpage as it helps to increase visitors on your webpage. Facebook has 2 billions more users. So, by adding Facebook share button, you will allow visitors to share your article or web page on easy way. 

In this article, I am showing you how you can add Facebook share button in your blog or website without creating app id. Find the code below and add on your website or blog.

HTML

<button type="button" class="btn btn-primary" id="facebookLink" data-url="URL_OF_YOUR_WEBPAGE">
Facebook Share
</button>

Javascript/JQuery

 <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

<script>
(function($){
    "use strict";
    
     //console.log('mounted');
     $("#facebookLink").on("click",function(){
      let url = $(this).data('url');
     var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u=" + url, "pop", "width=600, height=400, scrollbars=no");
     return false;
    });

    $("body").append("<div id='fbcredit'><a href='https://www.allblogsolution.com/2021/02/how-to-add-facebook-share-button.html' target='new'>Add FB Share Button</a></div>");
    $("#fbcredit a").css({'font-size':'9px','color':'#f3f3f3'});
 })(jQuery);
</script>

Note: You have to replace URL_OF_YOUR_WEBPAGE by your webpage url. And I have not provided stylesheet code here as you can code whatever style you want to apply on this facebook share button. And you also can remove the credit given to allblogsolution.


0 Comments :

Post a Comment

Any comment will be appreciated, comment will be published according to our comment policy