How to show particular block or div from my entire page when i share with image and title on facebook

49 Views Asked by At

I found many codes but not working for me, I want to share a page but show particular block or div from my entire page when I share with image and title on Facebook.

when I share result should look like. enter image description here

my code

<div class="content">

    <div id="mImageBox">

      <img id='my_image'  src='https://i.imgur.com/C8VWSZP.jpg' alt='tis is title' width="100%"
       onclick="fbs_click(this)"/>

      </div>

      <script>
         function fbs_click(TheImg) {
         u=TheImg.src;
         // t=document.title;
        t=TheImg.getAttribute('alt');
        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>
 </div>

My code work perfect only for image share not working for image and Page URL. i want to share current page URL. it should be dynamic.

0

There are 0 best solutions below