社交媒体分享页面外的特定内容

时间:2016-01-29 11:23:40

标签: facebook share fbml fbsdksharekit

我的社交媒体共享代码存在问题。

请参阅下面的代码:

//我想在facebook上点击facebook分享按钮分享这个div(id =" maindiv")...

<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>

所以问题是我在我的网站上发布了多个工作,我需要将这个共享按钮添加到每个div,而不是整页。我已完成整页共享的编码,但需要帮助才能共享页面的某些部分或div。

1 个答案:

答案 0 :(得分:0)

  <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'));
相关问题