Unify Logo Footer.svg
Unify Applications
Logo
Iframe & Code Editor

Iframe & Code Editor

Logo

7 mins READ

Iframe

The Iframe block embeds another web page — or a snippet of raw HTML — inside your app. You point it at a URL or paste HTML to embed, control what the embedded content can do through permission toggles, and react to messages the embedded page sends your app. Inline HTML embeds can additionally be made editable, turning the block into a live HTML editing surface.

Tip: When to use Iframe: Embed an external tool, dashboard, map or documentation page without leaving your app. Render raw HTML you already have (email preview, generated markup). Build a two-way integration with an embedded page via postMessage. For displaying a single image or video, use Image or Video blocks instead — they're lighter and not sandboxed.

Properties

Content — Source

PropertyTypeDefaultDescription
srcstring (URL, bindable)https://www.unifyapps.comThe URL of the page to embed.
srcDocstring (HTML, bindable)Inline HTML to embed, overriding the URL.
contentEditablebooleanfalseInline HTML only. (optional) Lets the user edit the embedded HTML directly in place.

Content — Sandbox Permissions (Attributes)

All permissions start off. Enable only what the embedded content requires.

ToggleWhat it allows
DownloadsFile downloads from within the embed.
FormsForm submissions inside the embed.
PopupsOpening new windows or tabs.
ModalsPrint, alert, confirm, and prompt dialogs.
FullscreenFullscreen display.
Top NavigationLinks and code navigating your whole app away.
Top Navigation by User ActivationNavigating away only from a user click.
CameraCamera use within the embed.
MicrophoneMicrophone use within the embed.
GeolocationLocation access within the embed.
Storage and CookiesBrowser storage and cookies (effectively always on — see gotchas).

Appearance

PropertyTypeDefaultDescription
stylesstyle set540×360 pxWidth, height, min/max, margin, padding, border, radius.

Events

EventTriggerPayload
On Message ReceivedThe embedded page calls window.parent.postMessage()The message data sent from the embedded page

Methods

MethodParamsEffect
Send MessagemessagePosts a message to the embedded page via postMessage.
Get HTML ContentReturns the current HTML content of the embed (inline / editable mode only).

Behavior & Gotchas

Warning: Many external sites block iframe embedding. If the target site sends an X-Frame-Options: DENY or a restrictive Content-Security-Policy, the browser refuses to embed it and the block shows a blank frame with no error. Test embedding before designing a flow around it.

Warning: Storage and Cookies is effectively always on. The sandbox attribute removes the storage restriction by default to allow basic page functionality. Toggling it off in the inspector restores the restriction but can break embedded pages that rely on cookies.

Note: ContentEditable only appears for inline HTML embeds. The option is hidden while a URL is set. The Get HTML Content method reads back the user's edits.

Examples

Code Editor

The Code Editor block provides a syntax-highlighted code editor for viewing or editing code and structured text in your app. It supports nine languages (JSON, JavaScript, TypeScript, Java, Python, Shell, SQL, Markdown, YAML), optional line numbers, light or dark theme, and an editable or read-only mode.

Tip: When to use: Show API responses, configuration, or logs with proper syntax highlighting (turn Editable off for a read-only viewer). Let users author a script, query, or JSON payload inside your app. Prefer a plain text area when the content isn't code.

Properties

PropertyTypeDefaultDescription
payloadstringSets the editor's value on initial render. If the default value is a dynamic expression, the editor content updates when the value changes.
language"json" | "javascript" | "typescript" | "java" | "python" | "shell" | "sql" | "markdown" | "yaml"jsonThe language used for syntax highlighting.
editablebooleanWhether the user can type in the editor. When off, the editor is read-only.
lineNumberbooleanShows or hides line numbers in the gutter.
themeinherit | light | darklightLight or dark editor theme. Inherit follows the app theme.

Events

EventTrigger
On ChangeContent in the editor changes. Payload: the full current content string.

Exposed State

State keyTypeDescription
{{ id.value }}stringThe current content of the editor.

Examples

JSON Schema Editor

The JSON Schema Editor block gives your users a visual editor for building an object schema — they add, nest, reorder and configure fields in a tree view instead of writing JSON by hand. You seed it with a starting schema through the Input property, the user edits it on screen, and every edit updates the block's state and fires On Change so you can save the result. A freshly dropped block arrives pre-filled with a sample schema containing a single name text field.

Tip: When to use: Let end users define or edit a data structure — custom object fields, API payload shapes, form schemas — without writing JSON. Build admin screens where the schema authored here is saved and later drives another surface (e.g. a Form block bound to it). For collecting plain values rather than designing a schema, use a Form block instead.

Properties

PropertyTypeDefaultDescription
inputstring (schema object, bindable)Sample schema with name fieldThe schema the editor starts from. The user's edits build on it.

Events

EventTriggerPayload
On ChangeAny edit — a field added, removed, renamed, retyped or reorderedinput — the full edited schema

Exposed State

State keyTypeDescription
{{ id.input }}objectThe current schema after any user edits.

Behavior & Gotchas

Note: The Input binding seeds the editor; it doesn't override edits. If you bind Input to a data source value, the editor is populated on first load. But subsequent changes by the user are tracked in the block's state ({{ id.input }}), not written back to your data source. Save explicitly on On Change.

Examples

BlockRelationship
ImageDisplay a single image without the sandbox overhead of an iframe.
VideoDisplay a video without the sandbox overhead of an iframe.
FormCollects values from users; use instead of Schema Editor when collecting data, not designing schemas.
Text AreaPlain multi-line text input for prose — use instead of Code Editor when the content isn't code.

Frequently Asked Questions

Why does my Iframe show "Refused to connect" instead of the page?

The most common cause is an X-Frame-Options or Content-Security-Policy: frame-ancestors header on the target site that blocks embedding in iframes. This is a browser security policy enforced on the embedded page, not a configuration in UnifyApps. You cannot override it in the Iframe block settings. Use srcDoc with inline HTML instead of src, or contact the target site's owner for an embeddable URL. Sites like Google, GitHub and most social platforms block iframe embedding.

How do I pass data from my page into the embedded Iframe and receive responses?

Use the Send Message method on the Iframe block to post a JavaScript object to the iframe's window. The embedded page receives it via a standard window.addEventListener('message', ...) handler. Conversely, when the embedded page calls window.parent.postMessage(data, '*'), the Iframe block fires its On Message Received event with the payload — use that event to update page variables or call automations in response.

Can I let users edit the Code Editor's content and save it?

Yes. Set the Editable property to true. The block exposes {{ id.value }} in state, which updates on every change (On Change event also fires). Bind a Save button to read {{ codeEditor1.value }} and pass it to your data source. To programmatically set content, bind the payload property to a string expression — note that once the user edits the content, changes to the payload binding do not overwrite what the user typed.

Does the JSON Schema Editor work as a form field I can bind to save the schema?

The JSON Schema Editor exposes the full schema object as {{ id.input }} in state, and fires On Change on every edit. You can read that state at any time — for example, on a Save button's On Click — and write it to your data source. To seed the editor with an existing schema, bind the Input property to that schema object. Note that binding changes do not override edits the user has already made in the current session — the user's edits always take precedence.