social media share specific content out of page

1.4k views Asked by At

I am having some issue with my social media share code.

See my code below:

// I want to share this div (id="maindiv") at facebook on click of facebook share button...

<html>
  <head>

  </head>    
  <body> 

    <div id="fb-root"></div>
    <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 = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=17968886776";
        fjs.parentNode.insertBefore(js, fjs);
    }
    (document, 'script', 'facebook-jssdk'));

    </script>



    <div id="maindiv1" style="border:1px solid blue;width:500px;height:230px">            
        <div  style="border:0px solid red;width:100px;height:80px;float:left;">
         <img src="http://localhost:8080/pushnotification/img/small-icon.png" /><img>
        </div>
        <h1 style="color:blue;font-family:sans-serif;float:left;width:390px;margin-top:10;text-align:center;border:0px solid red;">enterployee.com</h1>
       <div style="border:0px solid red;width:100%;height:120px;float:left;">
        <p style="font-family:sans-serif;font-size:15px;">
           Enterployee.com is a employee relationship management tool for enterprise. It’s a fully managed notification platform for employees.
  We have a vision to make organizations more professional and organized. After getting an enterployee account organizations can notify their employees easily and employees can connect with their company in better way.
           </p>

        </div>

        <div style="border:0px solid red;width:80px;height:30px;float:right;">
        <div class="fb-share-button" data-href="http://localhost:8080/pushnotification/img/small-icon.png" data-layout="button"></div>
        </div>
    </div>                
</body>

So the problem is that I have multiple jobs posting in my site and I need to add this share button to each individual divs, not the full page. I have done the coding for full page share but need help in sharing only some part of page or a div.

1

There are 1 answers

2
sonam Sharma On
  <div class="fb-share-button" data-href="y" data-layout="our urlherebutton"></div>


   (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 = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
  fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));