Problem with Random quote machine in codepen

Problem with Random quote machine in codepen
0

#1

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:

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


#2

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.


#3

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


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

#5

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


#6

Did you first click “New quote”?

EDIT: this is what I get.
afbeelding


#7

yes, maybe some bugs in code


#8

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


#10

So do you see a quote on your site?


#11

no, github page also do not work


#13

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


#14

I find the problem =) thanks


#15

But know it opens two windows =) omg


#16

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


#17

Thanks, I’ll try to fix it


#18

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