Random Quote Tweet Button Troubles

Random Quote Tweet Button Troubles
0

#1

So I have everything I need for the random quote machine to work, but I can’t seem to figure out how to get the tweet button to work. The closest I’ve gotten is getting the twitter window to open, the text to populate with a string I have set, but the index of my array shows up instead of the quote text. It’s rather frustrating.

Any ideas? I know I’m close, I just don’t stuck at the moment.

Here’s my codepen: http://codepen.io/Qwicksilver/pen/xOjPdx


#2

Hi, @danijmoss.

A quick workaround would be

  1. Create a global tweetUrl variable at the top of your code.
  2. Add tweetUrl = 'https://twitter.com/intent/tweet?text=' + aquote[rdmQuote] + ' - Rick Sanchez'; right after the line that chooses a random index.
  3. Write window.open(tweetUrl); inside the tweet() function.

#3

That was exactly what I needed. Thank you! That was driving me insane for most of the night last night. :slight_smile:


#4

Thank you! You’re a star :slight_smile:


#5

Hello, I’m having some problems with the tweet button as well. I implemented the method used in this thread but there still seems to be a problem.

Here’s the link to my codepen: https://codepen.io/mayankgupta02/pen/WOMBjK?editors=1010