Digital Highrise

A blog by Aaron Friedman

  • Home
  • About Aaron
  • Guest Blogger
    • Search Engine Land
    • Radian6
  • Hear me Speak
  • Contact
You are here: Home / Guest Blogger / Search Engine Land / Tweet What You Want Code on Search Engine Land

Tweet What You Want Code on Search Engine Land

May 30, 2012 by Aaron Friedman 1 Comment

I recently wrote an article on Search Engine Land and wanted to make sure I posted the code in other places as well in case anyone missed it.

Basically, the code is used to make sure you decide what users tweet.

This is a quick work around that I came up with and my friend Josh (my go-to developer) who helped me put it together.

Simply install this code in the place where you would place a Twitter share button:

<a href=”#” onclick=”tweetSelectedText()”><img src=”http://digitalhighrise.com/wp-content/uploads/2012/05/tweet_button.gif” border=”0″ /></a>

       <script type=”text/javascript” src=”http://code.jquery.com/jquery-1.7.2.min.js”></script>

       <script type=”text/javascript”>

       $().ready(function(){$(‘.tweetThis’).hide();});

       function tweetSelectedText(){

               var twtTitle = $(‘.tweetThis’).text() || $(‘title’).text();

               var twtUrl = location.href;

               var maxLength = 140 – (twtUrl.length + 1);

               if (twtTitle.length > maxLength) {

                       twtTitle = twtTitle.substr(0, (maxLength – 3))+’…’;

               }

               var twtLink = ‘http://twitter.com/home?status=’+encodeURIComponent(twtTitle + ‘ ‘ + twtUrl);

               newwindow=window.open(twtLink,’name’,’height=500,width=500′);

               if (window.focus) {newwindow.focus()}

       }

       </script>

Then, in the code of your post (beginning or end, it doesn’t make a difference) add this tag:

<p class= “tweetThis”>THIS IS WHERE YOUR MESSAGE GOES</p>

In this tag, you can craft your own message, which is descriptive, contains the targeted keywords and utilizes the allotted space.

 

And that’s it. Hope that helps 🙂

 

Filed Under: Search Engine Land, Technology, Twitter

My Name Is Aaron Friedman

Aaron Friedman headshot

What Digital Highrise Is All About

I am always finding great things online. Bout time I made a repository of sorts to keep track of it all. So here it is! Digital Highrise will be my repository of anything Digital, anything Viral, and anything that just makes you laugh.

In this Digital world, we need all the ammo we can to rise to the top.

Browse Around

Recent Posts

  • Levels of Laziness
  • Artificial Nostolgia
  • Abstract Career Path
  • Appreciate Our V1 Foundation
  • Always Take a Glass of Water

Hear Me Speak

Copyright © 2025 · Beautiful Pro Theme on Genesis Framework · WordPress · Log in