Mortiferr Mortiferr - 10 months ago 34
Javascript Question

Tweet something based on JavaScript variable

I have my Codepen which can be found here (

I have a button like so:

<button onclick ="tweetIt()" class="twitter" href="#twitter"><i class="fa fa-twitter fa-lg"></i> Tweet Quote</button>

It is a random quote machine that generates a random quote from an API. I want to make it so that the user can tweet out the quote on the screen. I have a variable called
so I need to somehow use those to send out the tweet.



Thanks for all the help everyone -.-

Here's how I did it:

$('.twitter').on('click', function() {
  makeTwitterPage('' + encodeURIComponent('"' + quote + '" ' + author));
function makeTwitterPage(url){, 'Share', 'width=700, height=500, toolbar=0, scrollbars=1 ,location=0 ,statusbar=0,menubar=0, resizable=1');