How do i insert Javascript into a Topic?

For example i would like to insert a optinmonster Optin. This should be the code:

<!-- This site is converting visitors into subscribers and customers with OptinMonster - http://optinmonster.com -->
<div id="om-o1ozq0it5dg9dp9v-holder"></div>
<script>
var o1ozq0it5dg9dp9v,o1ozq0it5dg9dp9v_poll=function(){var r=0;return function(n,l){clearInterval(r),r=setInterval(n,l)}}();!function(e,t,n){if(e.getElementById(n)){o1ozq0it5dg9dp9v_poll(function(){if(window['om_loaded']){if(!o1ozq0it5dg9dp9v){o1ozq0it5dg9dp9v=new OptinMonsterApp();return o1ozq0it5dg9dp9v.init({u:"17705.331160",staging:0,dev:0,beta:0});}}},25);return;}var d=false,o=e.createElement(t);o.id=n,o.src="//a.optnmnstr.com/app/js/api.min.js",o.onload=o.onreadystatechange=function(){if(!d){if(!this.readyState||this.readyState==="loaded"||this.readyState==="complete"){try{d=om_loaded=true;o1ozq0it5dg9dp9v=new OptinMonsterApp();o1ozq0it5dg9dp9v.init({u:"17705.331160",staging:0,dev:0,beta:0});o.onload=o.onreadystatechange=null;}catch(t){}}}};(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(o)}(document,"script","omapi-script");
</script>
<!-- / OptinMonster -->

If i paste it into a topic it won’t show. Is there a way to make it work natively?

You can only insert JS via Admin, Customize in the header or footer.

5 « J'aime »

First off let me thank you for the quick answer. Is there a plugin (i’ve searched but didn’t find anything) to let me put js in a topic? Or should i make a plugin by miself?

1 « J'aime »

I would like to do this too. It would permit posting material in particular categories in some sort of logical place you’d expect to find it and not be limited to the header and footer (assuming you aren’t proficient in code).

I need to do this too!

Est-il possible d’insérer du code JS dans une page de catégorie ou dans un sujet ?

Vous ajoutez du JS à un thème, et dans le code JS, vous pouvez cibler des catégories ou des sujets spécifiques à l’aide de sélecteurs DOM.

2 « J'aime »

Merci pour votre réponse rapide. Je vais me pencher sur le DOM, car pour le moment, je ne sais pas comment il fonctionne.

Ce sujet a été automatiquement fermé après 2943 jours. Les nouvelles réponses ne sont plus autorisées.