显示重复的Twitter按钮

时间:2015-09-16 16:33:24

标签: javascript twitter

我动态构建HTML页面,除了Twitter共享按钮多次显示外,一切都很顺利。

enter image description here

我查看了网页来源,并没有向我跳出来。

这里是吐出Facebook和Twitter按钮的代码。作为一个数据库人员,我很少知道它意味着什么,因为它只是这些供应商提供的示例代码的剪切和粘贴。

<p>
  <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/all.js#xfbml=1&appId=620849677946889";
   fjs.parentNode.insertBefore(js, fjs);}
    (document, 'script', 'facebook-jssdk'));
 </script>
<div class="fb-like" data-href="https://www.yahoo.com" data-width="400" data-show-faces="True" data-send="True" data-colorscheme="light" data-layout="standard" data-action="like"></div></p>


<p>
  <a href="https://twitter.com/share" class="twitter-share-button"data-related="whitehouse,Zerohedge" data-lang="en" data-size="large" data-hashtags="lawyers,guns,money" data-count="horizontal" data-text="Stuff" data-URL="Stuff" data-via="http://www.zerohedge.com"</a>
<script>
  !function(d,s,id){
    var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
    if(!d.getElementById(id)){
     js=d.createElement(s);
     js.id=id;js.src=p+'://platform.twitter.com/widgets.js';
     fjs.parentNode.insertBefore(js,fjs);}}
     (document, 'script', 'twitter-wjs');</script></p>

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

我不确定你为什么这么多。 我重新生成它,它现在似乎有效。

以下是代码:

    <p><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/all.js#xfbml=1&appId=620849677946889";  fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script><div class="fb-like" data-href="https://www.yahoo.com" data-width="400" data-show-faces="True" data-send="True" data-colorscheme="light" data-layout="standard" data-action="like"></div></p>


    <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.zerohedge.com" data-via="James0888" data-size="large">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

您可能只想在Twitter的网站上重新生成它。

答案 1 :(得分:0)

<a>标签不合适 替换

<a href="https://twitter.com/share" class="twitter-share-button" data-related="whitehouse,Zerohedge" data-lang="en" data-size="large" data-hashtags="lawyers,guns,money" data-count="horizontal" data-text="Stuff" data-URL="Stuff" data-via="http://www.zerohedge.com"</a>

<a href="https://twitter.com/share" class="twitter-share-button" data-related="whitehouse,Zerohedge" data-lang="en" data-size="large" data-hashtags="lawyers,guns,money" data-count="horizontal" data-text="Stuff" data-URL="Stuff" data-via="http://www.zerohedge.com">some text??</a>