Problem with Random quote machine in codepen

Hi. There is a link to my github page with quote machine:
https://serafimpoch.github.io/-Random-Quote-Machine/

Everything works great. But in codepen:
https://codepen.io/SerafimPoch/full/oELxLB/

twitter button does not work. Who know how to fix ? Thanks

On Codepen your code is displayed inside an iframe and it does not allow to load other sites inside of it. And that is exactly what you are doing by setting location.href. So if you want it to work with Codepen, you will have to open twitter in a new tab.

Could you please help me ? Cause window.open( ) does not work right =)

//location.href = twitter + x
window.open(twitter+x);

still nothing, just open page without quote. Ok thanks =)

Did you first click “New quote”?

EDIT: this is what I get.
afbeelding

yes, maybe some bugs in code

So do you get the ‘#quotes’ inside the tweet box?

So do you see a quote on your site?

no, github page also do not work

Yeah, if you are blocking the pop-ups it won’t work

1 Like

I find the problem =) thanks

But know it opens two windows =) omg

That is because you are adding multiple eventListeners (every time you click ‘new quote’).

Thanks, I’ll try to fix it

I used this to tweet

 window.open("https://twitter.com/intent/tweet?text=" + $("#quote").html());

Opening twitter to tweet + the value of the element where the tweet is store down on my page $("#quote").html());

Credit - this video at 3:08 https://www.youtube.com/watch?v=4SzSMXiXrCM&index=3&list=PLHdCowjFIBmJFE01bYJzhyearw_xC0oED