Hi,
For tweeting the random quote, is an API needed and do we need to send the tweet to a server?
I went through the forum and i have seen some posts where people have used a URL i.e (https://twitter.com/intent/tweet?text=)
Hi,
For tweeting the random quote, is an API needed and do we need to send the tweet to a server?
I went through the forum and i have seen some posts where people have used a URL i.e (https://twitter.com/intent/tweet?text=)
Thatâs the link provided by the challenge instructions. It will work to pass the tests, and it will work to take you to the twitter âtweetâ page, but it will not include the text from your random quote.
Thanks for the quick response. I did not notice it, my bad. I have just tried to do this but my code keeps opening a blank page. A snippet of my code is below. Canât figure out what iâm doing wrong
$(â#tweet-quoteâ).click(function() {
window.open('https://twitter.com/intent/tweet?text=â+ document.getElementById(âtextâ).innerHTML);
});
Are you building this in CodePen? Or do you have a live version I can view elsewhere?
Perfect!
Okay, after playing with it hereâs what Iâve discovered. You have two errors to correct before that link will work:
" "
which is breaking the link and resulting in about:blank<p>
tags in the link, which doesnât prevent the link from working but means my tweet text includes them.thanks for the response. shouldnât the link be in quotes? not sure i understand what you mean by quote text
By âquote textâ I meant the text of your quote.
The stuff you get with document.getElementById("text").innerHTML
right, i see.
document.getElementById(âtextâ).innerHTML is not empty though it actually contains a quote. Maybe i need to take a different approach. Thanks for the help!
No, itâs not empty.
But it includes the spaces between the words.
So your url becomes https://twitter.com/intent/tweet?text=This is a quote
URLs canât have spaces in them - spaces are represented with %20
.
oh wow this works. Thanks! I thought âinnerhtmlâ and âtextContentâ pretty much did the same things
textContent actually returns all the html removed content
You can refer this
Plesae mark this as solved if you feel like it.