【问题标题】:Social Bookmarking using ShareThis : javascript error 'SHARETHIS is undefined'使用 ShareThis 的社交书签:javascript 错误“SHARETHIS 未定义”
【发布时间】:2011-07-29 21:22:39
【问题描述】:

我在使用 ShareThis 社交书签实用程序的页面中收到“SHARETHIS 未定义”。这是我的代码

<HTML>
 <HEAD>
  <TITLE>Demo</TITLE>

  <script type="text/javascript">var switchTo5x=true;</script>
  <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
  <script type="text/javascript">stLight.options({publisher:'f5b1585e-488a-403c-8b7e-ade3efab880a'});</script>
 </HEAD>

 <BODY>
  <span class='st_sharethis' displayText='ShareThis'></span>
  <script type="text/javascript">
        SHARETHIS.addEntry({
            url:'http://www.google.com'
        }, {button:true} );
    </script>
  </BODY>
</HTML>

谁能告诉我可能是什么问题以及如何解决?

谢谢, 阿米特·帕特尔

【问题讨论】:

    标签: javascript html


    【解决方案1】:

    我使用 Firebug 检查了 DOM。没有名为 SHARETHIS 的变量。但是,有一个名为stWidget 的变量具有函数addEntry。我用stWidget 替换了SHARETHIS 并且没有错误。我不知道小部件的正确行为,但没有错误。

    编辑:将代码更改为共享 google.com 而不是当前网址。

     <HTML>
     <HEAD>
      <TITLE>Demo</TITLE>
    
      <script type="text/javascript">var switchTo5x=true;</script>
      <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
      <script type="text/javascript">stLight.options({publisher:'f5b1585e-488a-403c-8b7e-ade3efab880a'});</script>
     </HEAD>
    
     <BODY>
      <span class='st_sharethis' st_url="http://www.google.com" st_title="Google" displayText="Share This"></span>  
      </BODY>
    </HTML>
    

    【讨论】:

    • 谢谢阿拉文丹。现在错误消失了。但是该功能没有按预期工作。它应该共享 google.com 而不是共享当前页面。
    • 请查看 ShareThis.com 网站中的 API。help.sharethis.com/customization/share-properties 您需要更改您的 span 标签。
    • 更改代码以共享 google.com。如果可行,请“接受”答案。
    猜你喜欢
    • 2013-02-11
    • 2017-08-28
    • 2012-02-24
    • 2023-03-12
    • 1970-01-01
    • 2011-11-02
    • 2019-01-14
    • 2023-01-31
    • 1970-01-01
    相关资源
    最近更新 更多