How can i add text to the text area in the new tab that opens when i hit the “tweet button” ( using JavaScript?

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.

1 Like


'' + ...

1 Like

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

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: