Twitter button problem,the quote generator project

Twitter button problem,the quote generator project
0

#1

i hava a trouble with the twitter button it shows a blank page,can anybody help me,here is the code pen link https://codepen.io/mehdij/pen/goMZQN/
ps: it is not responsive i did not use bootstrap,and i will style a little the page


#2
document.getElementById('quoteDisplay').innerHTML= quotes[randomNumber]
       };

function tweetQuote() {
       var twitterURL = 'https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=';
       var q = $("#quotedisplay").text();

Only thing i caught was lack of consistent casing with quoteDisplay (q uses quotedisplay)


#3

thanks a lot ,i changed the values to’ quoteDisplay’ to both of them,but i still have the same problem


#4

Codepen does not allow you to load an external page when you click on a link directly. You can add target="_blank" to the anchor tag inside the Tweet button and a new window will open. However, you will need to add some JavaScript to put the quote into the Tweet textarea box in the new window.


#5

thank a lot,i changed the javascript in order to put the quote into the tweet,it does not work,it shows a an empty quote,since i am beginner i have no idea how to change the code to fill the twitter box,would you
mind helping me to do it


#6

You currently have a function called tweetQuote (see below) which returns a URL constructed using what is currently in the div with id=“quoteDisplay”.

function tweetQuote() {
  var twitterURL = 'https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text="';
  var q = $("#quoteDisplay").text();
  twitterURL += encodeURIComponent('"' + q + '"');
  return twitterURL;
}

You also have the following line of code.

$("#tweet").attr("href", tweetQuote());

Why don’t you put the above line inside your newQuote function, so the Tweet url gets updated each time a newQuote is displayed?


#7

oh thanks you!!!,finaly it works!!!