JSFiddle - React, Tailwind, and code Playground

HTML

<iframe srcdoc="
  <!DOCTYPE html>
  <html>
  <head>
    <meta charset=&quot;utf-8&quot;>
  </head>
  <body>
    <code>iframe</code>
  </body>
  </html>
"></iframe>

JavaScript

var iframe = document.getElementsByTagName('iframe')[0];
iframe.addEventListener("load", function() {
		/* the JS equivalent of the answer
     *
     * var node = document.createElement('style');
     * node.appendChild(document.createTextNode('body { background: #fff; }'));
     * window.frames[0].document.head.appendChild(node);
     */
    
    // the cleaner and simpler way
    window.frames[0].document.body.style.backgroundColor = "#fff";
});