2011-04-05 69 views
0

我收到「SHARETHIS是未定義」在我用ShareThis社交書籤工具的頁面。這裏是我的代碼社會書籤使用ShareThis:JavaScript錯誤「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> 

任何人都可以請告訴我可能是什麼問題以及如何解決?

謝謝, 阿米特帕特爾

回答

3

我使用螢火蟲檢查的DOM。沒有名爲SHARETHIS的變量。然而,有一個名爲stWidget具有功能addEntry變量。我換成SHARETHISstWidget,並沒有任何錯誤。我不知道小部件的正確行爲,但沒有錯誤。

編輯:改變了代碼共享google.com取代當前的URL。

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

謝謝Aravindan。現在錯誤消失了。但功能不能按預期工作。它應該共享google.com,而不是共享當前頁面。 – 2011-04-07 11:24:24

+0

請看看ShareThis.com網站的API .. http://help.sharethis.com/customization/share-properties您需要更改您的跨度標籤。 – 2011-04-07 17:09:30

+0

更改了代碼以共享google.com。如果有效,請「接受」答案。 – 2011-04-07 17:11:31