Popup doesn't work with CodePen

Popup doesn't work with CodePen
0.0 0

#1

So I found this code online of adding a Twitter button to your website. It basically popups a window allowing the user to tweet the content. However this code doesn’t work in codepen even though it works fine on the local machine.
Any help would be much appreciated.
Codepen page
popup function code

$(’.popup’).click(function(event) {

var width  = 575,
    href="http://twitter.com/share";
    height = 400,
    left   = ($(window).width()  - width)  / 2,
    top    = ($(window).height() - height) / 2,
    txt=$("#quote").html().split('.')[0].split(' ').join('%20'),
    url    = href+"?text="+txt,
    opts   = 'status=1' +
                ',width='  + width  +
                ',height=' + height +
                ',top='    + top    +
                ',left='   + left;
    console.log(opts);

window.open(url, 'twitter', opts);

return false;

});


#2

Looking at the console with devtools:


#3

Yeah it’s a sandboxed environment, I’d be exceptionally surprised if it let you open windows with JS. Plus it’s http rather than Https so I think they’ll be an error showing for that. In a normal browser environment you have to manually agree to allow popups as they’re blocked by default almost everywhere. Open the browser console, you should see an error message in the console with an explanation.