question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quote Machine Tweet button doesn't work on CodePen due to Twitter's API

See original GitHub issue

Describe your problem and how to reproduce it: The Tweet button on the Quote Machine project isn’t working due to twitter.com refusing to connect and a ERR_BLOCKED_BY_RESPONSE error. User story 10 in the instructions for this project states

I can tweet the current quote by clicking on the #tweet-quote a element. This a element should include the "twitter.com/intent/tweet" path in its href attribute to tweet the current quote.

So I did some digging in Twitter’s web intents documentation and found that web intents cannot be loaded inside an iframe (about halfway through Working with Web Intents section).

I looked into how CodePen renders its projects, and in both the editor and full views, it renders as an iframe. Since the user has no control over Twitter’s rules, or how CodePen renders the project, I don’t know how a tweet button could be successfully implemented in this project. Maybe posting to another social media site could be implemented instead?

Add a Link to the page with the problem:

Tell us about your browser and operating system:

  • Browser Name: Google Chrome
  • Browser Version: 86.0.4240.111
  • Operating System: MacOS Catalina (10.15.6)

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):

Screen Shot 2020-10-25 at 4 24 41 PM

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
naomi-lgbtcommented, Oct 29, 2020

I think @moT01’s suggestion of adding a hint is a good approach here. Something like:

Note: If you are developing this on CodePen, the restrictions prevent the Twitter link from loading in the window. Add the target="_blank" attribute as a workaround.

0reactions
acxdccommented, Apr 27, 2022

Even doing what is mentioned in that note at the bottom, I am still having this issue. Twitter is blocked if I just click the button whether target=“_blank” or target=“_top”. If I right click, and then click “Open in new tab”, it opens in a new tab without a problem, regardless of the target attribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quote Machine Tweet button error on CodePen due to Twitter ...
I was looking back over my old certification projects and I realized that the tweet button on my Quote Machine project wasn't working....
Read more >
Twitter "Tweet" button not working - Stack Overflow
Without that Javascript loaded, the only information that Twitter has is the referrer -- in this case, that's something internal to Codepen.
Read more >
Build a Random Quote Machine (Forismatic API) - CodePen
A Free Code Camp Project. This site will display random quotes using the Forismatic API. You can see the code and learn to...
Read more >
Random Quote Machine - CodePen
A random quote machine/generator. To view random quotes and who said them, just click/tap the "View Random Quote" button. If you like a...
Read more >
QGmachine - CodePen
I hope you enjoy them as I learn to work with API and front end. ... <a class="twitter-share-button" href="https://twitter.com/intent/tweet" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found