1

I have created URL something like: http://example.com/namespace/page#img-3

I want to share my URL same as given above. But, when I share this URL to the social media it is sharing only page URL: http://example.com/namespace/page

without #img-3

#img-3 is the element id which I want to share from the page and pass it into the anchor tag to add in the URL

   <a href="#img-<?php echo $video->getId(); ?>">
        <img src="https://img.youtube.com/vi/<?php echo $video->getVideoUrl() ?>/0.jpg"/>
   </a>

I am using below FB share code:

<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11&appId=1336483029802737';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="<?php echo $baseURL_l.'video#img-'.$video->getId()?>" data-layout="button_count" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>
Vinod Kumar
  • 147
  • 2
  • 11
  • https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%websitename.com you can simply use this url to share – Umar Majeed Dec 26 '17 at 09:23
  • 1
    There is answer on fallowing link. https://stackoverflow.com/questions/9610156/using-hash-tags-with-facebook-share-possible/11271090 – FGDeveloper Dec 26 '17 at 09:25

0 Answers0