Tweet Button vs Intents: Dynamically change tweet text


Hi everyone,

Twitter & web development newbie here. I have a Rails app that I would like to allow users to tweet from, so either the Tweet button or Intents seems like the right tool to use.

On the particular page, I have a table with selectable rows of products. I’d like to pre-populate the tweet text with what the user has selected from the table. There is no real need to talk back to my server with the selections -> I think it’s best to keep this all on the client side.

So, say the user selected the rows for “Apple Juice” and “Oscillating Fans”, I’d like the tweet link to launch with a default message of “I like Apple Juice and Oscillating Fans”. The user can change this of course, in the popup tweet window.

Using Intents, I was able to do this by changing the HREF property through Javascript. Cool!

But for some reason, I like the Tweet Button better (I like the picture). But it isn’t manipulable in the same way… it gets replaced by an IFRAME and the ID parameter doesn’t get preserved.

Is the Tweet Button the right tool for this job? Is it possible to dynamically change the text? My knowledge of Javascript and DOM is very low…



Hi Wayne,

It’s not explicitly documented for the Tweet Button, but you can specify a text parameter, just like the Tweet Web Intent, to indicate what pre-filled text you want for the Tweet Button.

For example:


…will yield the default text of “This will show up” when the Tweet Button is clicked.


Thanks Taylor, I’ll gave it a try. It appears it’s the widgets.js script to load the pretty button that replaces the anchor element. Leaving it out keeps the element there, and I can manipulate it. Looks like I’m stuck using the less pretty buttons. Thanks for your help!


Once you manipulate the DOM for this, you can ask widgets.js to re-evaluate the page and re-draw Tweet Buttons: twttr.widgets.load() – you may want to totally destroy the original Tweet Button’s DOM node and reinsert a new one with your new prepared text.


i have a site which shares quotes.
On hitting the “Tweet” button, I want the quote to be tweeted and not the link or the title.
How do I do it ?




hello testing is not runniung