如何将sharethis javascript嵌入到另一个javascript文件中?

时间:2009-12-05 18:57:22

标签: javascript

基本上这是我的代码,它将共享按钮添加到现有页面。现在我要做的是在twitter图片旁边添加sharethis按钮(通过javascript调用)(右侧)

分享javascript:

 <script type="text/javascript">
  (function() { 
   function replaceAll(text,strA,strB){while ( text.indexOf(strA) != -1)
  {text = text.replace(strA,strB);} return text;}
  var share = {"html":"<div class=\"share\" style=\"text-align: left;\">\n\
  <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n\t\t<tr>\n\t\t\t
   <td colspan=\"16\" style=\"padding: 0px;\">\n\t\t\t\t<h4 style=\"margin-bottom:   
   0px\">Share this with others! <\/h4>\n\t\t\t<\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t\n\t
   \t\t<td align=\"center\" style=\"padding: 0px 0px 0px 0px;\">
   <a href=\"http:\/\/twitter.com\/home?status=TTIITTLLEE (UURRLL)\" title=\"Click to 
   share this page on Twitter\"><img src=\"http:\/\/img.site.com\/images\/sm\/16
   \/Twitter%2001.png\" border=\"0\"\/><\/a><\/td>\n\t\t\t<td width=\"0\">   <\/td>
   \n\t\t<\/tr>\n\t<\/table>\n<\/div>"}; 


        share.html = replaceAll(share.html, "UURRLL", location.href);
        share.html = replaceAll(share.html, "TTIITTLLEE", document.title);

        $(function() {
            $("#question .post-taglist").append("<div style='float:right'>"+share.html+"</div>");
        });
    })();
    </script>

分享我正在尝试添加的按钮javascript:

<script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=394f24b1-b257-4daf-a92d-334c05a91b58&amp;type=website&amp;buttonText=More%20Services&amp;post_services=email%2Csms%2Caim%2Cmyspace%2Clinkedin%2Cfriendfeed%2Cwordpress%2Cblogger%2Ctypepad%2Cbebo%2Clivejournal%2Cxanga"></script>

任何人都可以帮我这样做吗?感谢

你们能告诉我新代码应该去哪里吗?

1 个答案:

答案 0 :(得分:1)

由于您似乎已经在使用jQuery,只需使用getScript()