Inserting ˂style˃ elements into mktoText areas (without having ’em stripped out)
We recommend that all Marketo LP templates have a place for page-level, just-in-time JS and CSS:
<div hidden class="mktoText" id="pageBehaviors" mktoName="Page Behaviors JS & CSS">
That’s where you put stuff when the client makes a last-minute request and you can’t change the global template for fear of side effects, nor are you comfy modifying shared Design Studio .js and .css files linked in the template.
In theory, you’d fill that Page Behaviors JS & CSS container like so:
Ah, but that won’t work. After clicking Apply, Marketo simply discards the <style> element!
The <script> element, in contrast, is supported. (Yes, it’s wrapped in old-school commented-CDATA but it works just fine.) Plus there’s a wrapper <div> added by default.[1]
So you end up with this:
That’s, er, problematic. But there’s an easy solution. First, include this JavaScript in all your templates:
<script>
class