Can you embed raw HTML into an iFrame dynamically via CMS?

Can you embed raw HTML into an iFrame dynamically via CMS?

I was trying to do this, but $w("#myHtmlComponent").src only allows for a https URL, not raw HTML. Is there another method I’m not seeing?

You can’t directly change the HTML of iFrame with Velo APIs.

But there are some workarounds you can try.

  1. Creating an API endpoint to return HTML code and use this API endpoint with .src API.
  2. Using a GitHub repo to store HTML code and use raw files from this GitHub repo to pass to .src API.
  3. Inserting HTML code using postMessage API of iFrame. (Works with onMessage API)
  4. If your HTML is something simple you can also use a text element. And use .html API to pass HTML code in it.

These are the workarounds (I know/remember) you can try.

1 Like

Thank you! This seems to be the way. I appreciate you!