Set Custom HTML in code?

The iframe’s like displaying a page in a new browser tab. Any paths have to be relative to the file being displayed in the iframe. That is different from working inside the Anvil environment.

You’re doing some JQuery manipulation by dynamically creating iframes and then replacing the Anvil content panel’s contents. You’re not actually changing the source of a single iframe that exists somewhere.

That’s apparently causing the issue you mention. I can’t comment on how to fix that (I stay away from that level of Javascript), other than to point you toward an iframe component that reuses an existing iframe and suggest that maybe looking at how it does things might help: IFrame Custom Component: Embed other websites in your app

That’s also a custom component you can use directly in your app.