1

我的社交媒体共享代码有一些问题。

请参阅下面的代码:

// 我想通过点击 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 的某些部分时需要帮助。

4

1 回答 1

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'));
于 2016-01-29T11:26:52.040 回答