Help tweeting text from a JavaScript Object


I’m trying to get tweet functionality for my random quote generator here working, so that it autofills the tweet box with the quote text and author. The quote and author are objects within a javascript array, which gets pushed to the webpage using innerHTML everytime the button is pressed.

Is there a simple way to do this?


You can create a new anchor element to place onto the page with text, url, and hashtag query parameters to pre-populate Tweet text.

You can also create a new Tweet button with a JavaScript factory function. A Tweet button is a web intent with styling recognized across the web.