How do I embed sharethis javascript into another javascript file?
Basically here is the code I have, it adds the share buttons to the existing page. Now what I want to do, is add the sharethis button(which gets called via javascript) next to the twitter image(on the right)
Share 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\">&l开发者_开发知识库t;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>
Sharethis button javascript that I'm trying to add:
<script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=394f24b1-b257-4daf-a92d-334c05a91b58&type=website&buttonText=More%20Services&post_services=email%2Csms%2Caim%2Cmyspace%2Clinkedin%2Cfriendfeed%2Cwordpress%2Cblogger%2Ctypepad%2Cbebo%2Clivejournal%2Cxanga"></script>
Can anyone help me do this? Thanks
Can you guys also tell me where the new code should go?
Since you seem be using jQuery already, just use getScript()
精彩评论