Embed javascript code


#1

I want to add a quiz from playbuzz.com into a post using the javascript they offer. Is that possible? Just copy/past the code do not seams to work…


(Mittineague) #2

Goodness no. Allowing JavaScript (which BTW is not Java) would be a major security vulnerability.

Imagine something like a “all your cookie are belong to us” script :scream:


#3

But it could be allowed just for admins and moderators. I see playbuzz.com quizzes everywhere including facebook and large sites. How can they allow to add them is it is such a big security issue…


(Jay Pfaffman) #4

Probably not. Here’s what playbuzz.com wants you to be able to do when you paste their URL somewhere:


(Mittineague) #5

I wonder what the deal is with codepens that have JavaScript?


(Rafael dos Santos Silva) #6

Codepen is a good netizen and only executes random JS when you click on the play button.


Can we make custom oneboxes?
(Simon Cossar) #7

The playbuzz embed code has two parts - a script tag and a div tag. You can get it to load in Discourse by adding a site customization that appends the script tag to your forum’s head and then adds the div markup to the post that you want the quiz to appear in. This works, but it causes an error: Cannot read property 'offsetTop' of undefined. I’m guessing that’s related to Discourse infinite scrolling.

From looking at the Playbuzz forum - it’s a Discourse forum - probably the best way to do it would be to embed the quiz on a WordPress site with their WordPress plugin, and then embed an iframe on Discourse that has the WordPress page as it’s src. This works, but to get it setup correctly takes quite a lot of work.