Random Quote Machine, Twitter sharing problem [SOLVED]

Random Quote Machine, Twitter sharing problem [SOLVED]
0

#1

Hi there,:slight_smile:
I’m having an issue with sharing the quotes on Twitter; when I click to share the link takes me back to my own page at codepen, is there anyone that can help, please. Here is the link to project!


#2

Your twitter button works for me.


#3

It seems to work in Chrome but not in Firefox.

EDIT: My bad, it works on both, but not with the first quote, because you only set the url when the button “#new-quote” is clicked.


#4

Thanks for teaching me CSS fade-ins and gradients btw. ^^


#5

Does it actually take you to twitter with the quote ready to be twitted? because It keeps sending me back home I tried with both chrome and firefox, hmm, weird. thanks for response.


#6

Yes, except for the first quote.

Maybe the popup gets blocked for you?


#7

But for me still doesn’t I tried with firefox too, still keeps sending me to home. It’s interesting actually. thanks for response tho mate.


#8

It resends me back to THIS PAGE it’s a boomerang page.


#9

It opens in a new tab?


#10

After I went to boomerang link, I clicked again on twitter Icon and now worked! I think it was a server bug, or browser issue, thanks for the help. For the first quote that I hard coded do you know how can I make that shareable as well?


#11

You can either add this below your code (or somewhere else, as long as it runs directly):

$.getJSON(api_url, getQuote, 'jsonp');

Or if you want to keep your own hard-coded quote (since it fits the background-color or for whatever reason):

var firstQuote = "Not all treasure is silver and gold, mate.";
var firstAuthor = "Captain Jack Sparrow";

$('#tweet').attr('href', 'https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=' + encodeURIComponent('"' + firstQuote  + '" ' +  firstAuthor));

Or you can hard code the href yourself ofcourse.


#12

Thank you so much for your help mate.