1

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.

Brij Sharma
  • 361
  • 6
  • 19
  • You can not specify any parameters besides the URL to share dynamically any more, all other data is taken from the Open Graph meta tags the URL returns. You will need an individual URL for each individual piece of content you want to share; sharing the same page under the same URL with different title/description/thumbnail is not possible. – misorude Oct 15 '18 at 09:54
  • ok, I updated my question. – Brij Sharma Oct 15 '18 at 10:04
  • Possible duplicate of https://stackoverflow.com/questions/1138460/how-does-facebook-sharer-select-images-and-other-metadata-when-sharing-my-url – misorude Oct 15 '18 at 10:08
  • Thanks, it help me lots – Brij Sharma Oct 15 '18 at 10:58

0 Answers0