title: Chrome Violation when using document.write with generated iFrame source - alternative?
body: <p>I understand using document.write is discouraged for various reasons, however I'm using it to inject programmatically html generated into an iframe widget.</p>
  <pre><code>var iframe = document.createElement('iframe')
  document.body.appendChild(iframe)
  iframe.contentWindow.document.open()
  iframe.contentWindow.document.write(generateHtml())
  iframe.contentWindow.document.close()
  </code></pre>
  <p>This method works perfectly for my use case, however Chrome warns against document.write as you'd expect: <code>[Violation] Avoid using document.write().</code></p>
  <p>Is it possible to suppress or satisfy the warning or do I have to live with it?</p>
  <p>I believe it's the best method to inject html to an iframe, considering other ways that I have tried:</p>
  <ul>
  <li>Setting the src directly with <code>data:text/html; ...</code> - limitations around length</li>
  <li>Setting srcdoc with html - This is my fall back, but browser support could be an issue</li>
  <li>Encode html using btoa base64 and set src directly with <code>data:text/html;base64,...</code> - This didn't encode properly and yielded <code>Invalid regular expression: Range out of order in character class</code></li>
  </ul>
  <p>Appreciate any tips!</p>