Posted By

abhayr on 09/02/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

LyndseyPearce


Adding tweeter to ur site


 / Published in: JavaScript
 

  1. <a href="http://twitter.com/home?status=Just read post by @rodneyb about adding tweet this link to website. Read it here - http://bit.ly/3jF3qy"></a>
  2.  
  3. <script type="text/javascript">
  4. var twtTitle = document.title;
  5. var twtUrl = location.href;
  6. var maxLength = 140 - (twtUrl.length + 1);
  7. if (twtTitle.length > maxLength) {
  8. twtTitle = twtTitle.substr(0, (maxLength - 3))+'...';
  9. }
  10. var twtLink = 'http://twitter.com/home?status='+encodeURIComponent(twtTitle + ' ' + twtUrl);
  11. document.write('<a href="'+twtLink+'" target="_blank"'+'><img src="tweetthis.gif" border="0" alt="Tweet This!" /'+'><'+'/a>');
  12. </script>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: FederikoNavarro on September 3, 2010

I just completed my javascript homework by using this code. Thank you guys!

You need to login to post a comment.