How can i add text to the text area in the new tab that opens when i hit the “tweet button” (twitter.com/intent/tweet) using JavaScript?

How can i add text to the text area in the new tab that opens when i hit the “tweet button” (twitter.com/intent/tweet) using JavaScript?
0

#1

This problem has happened to me while doing my Random Quote Machine project in CodeCamp. I have tried things related to the data-text attribute but didn`t work.


#2

Concatenate.

'https://twitter.com/intent/tweet?hashtags=ilovehashtags&text=' + ...


#3

it depends how you are coding your twitter tweet button. If you are just hardcoding the url link to a button, then you can encode the quote and replace the href via javascript.

If you are using the twitter api, meaning including the asynchronus twitter-widget script and such per the api documentation then I’d like to say i have an answer but i dont yet. I am stuck on the same thing doing it this way. So if i eventually find an answer I will let you know…

  • Nao

#4

In response to my last post I did finally find a solution to this if there were going about it the way I was so if you are still interested at taking a look here’s my codepen with the solution: http://codepen.io/Ngoldberg/full/PpMvgm/