Adding a javascript in a post?

Hello,
I have a custom script (javascript) that I want to add in the end of my post. It is a affiliate graphic banner, and embedding it does not do anything right now.

Embedding this javascript code works well on my Wordpress website, so I assume this is a setting or something I need to activate on Discourse in order to work?

PS. I wanted to show the code here, but if I paste it in nothing shows.

You may need a plugin or at least a Theme Component.

JavaScript is not allowed in posts - can you imagine the potential mischief of allowing randoms to post javascript?

JavaScript is allowed in Theme Components (which are under the admin’s control) but that may not solve the whole problem.

Finally, because Discourse is built within the Ember framework, the exact order of despatch makes using random additional javascript scripts a little less predictable (hence why you may need a Theme Component or Plugin to integrate the code in the right way).

To post code you use three back ticks before and after. `

FYI Amazon affiliate links work. The javascript element is placed in a Theme Component and the link is placed in the post.

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.