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.

unify-applications-iframe-and-code-editor-01-iframe-block.png
unify-applications-iframe-and-code-editor-01-iframe-block.png

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 Media blocks instead — they're lighter and not sandboxed.

Properties

Content — Source

Property

Type

Default

Description

src

string (URL, bindable)

https://www.unifyapps.com

Shown as URL. The URL of the page to embed.

srcDoc

string (HTML, bindable)

—

Shown as HTML to embed. Inline HTML to embed. When it is filled, the HTML is shown instead of the URL. To use Content Editable, also clear the URL.

contentEditable

boolean

false

Shown as Content Editable, only when URL is empty and HTML to embed is filled. Lets the user edit the embedded HTML directly in place.

Content — Sandbox Permissions (Attributes)

All permissions start off, except Storage and Cookies, which is always on in web apps (see gotchas). Enable only what the embedded content requires.

Toggle

What it allows

Downloads

File downloads from within the embed.

Forms

Form submissions inside the embed.

Popups

Opening new windows or tabs.

Modals

Print, alert, confirm, and prompt dialogs.

Fullscreen

Fullscreen display.

Top Navigation

Links and code navigating your whole app away.

Top Navigation by User Activation

Navigating away only from a user click.

Top Navigation to Custom Protocols

Navigation to custom URL protocols like mailto: or tel:.

Camera

Camera use within the embed.

Microphone

Microphone use within the embed.

Geolocation

Location access within the embed.

Storage and Cookies

Browser storage and cookies (always on — see gotchas).

Appearance

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

Events

Event

Trigger

Payload

On Message Received

The embedded page calls window.parent.postMessage()

The message data sent from the embedded page, at {{ id.events.onMessageReceived.message }}

On Blur

An inline embed with Content Editable on loses focus

—

On Load

The embed finishes loading

—

Exposed State

State key

Type

Description

{{ id.html }}

string

The current HTML of the embed, including the user's edits. Inline embeds with Content Editable on only.

The Iframe block has no methods. It can receive messages from the embedded page, but it cannot send messages into it.

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: In web apps, Storage and Cookies is always on. The embed always runs with allow-scripts and allow-same-origin, so switching this toggle off does not block browser storage or cookies. Embed only content you trust.

Note: Content Editable only appears for inline HTML embeds, which means the URL field must be empty. A new Iframe block has https://www.unifyapps.com in URL, so clear it after you paste your HTML into HTML to embed. Read the user's edits from {{ id.html }}.

Warning: Your app's Content Security Policy can block the embed. If the app's CSP doesn't allow the embedded host, the block shows "Blocked by Content Security Policy", the blocked host and an Open CSP settings button that takes you to the CSP settings. Add the host to the app's CSP (frame-src) under Settings → Security → Content Security Policy. See App Settings & Privacy.

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 13 languages (JSON, JavaScript, TypeScript, C, C++, HTML, Java, Markdown, PHP, Python, Shell, SQL, 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

Property

Type

Default

Description

payload

string

—

Sets 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" | "c" | "cpp" | "html" | "java" | "markdown" | "php" | "python" | "shell" | "sql" | "typescript" | "yaml"

json

The language used for syntax highlighting.

editable

boolean

On

Whether the user can type in the editor. When off, the editor is read-only. A new Code Editor is editable.

lineNumber

boolean

On

Shows or hides line numbers in the gutter. A new Code Editor shows them.

theme

inherit | light | dark

inherit

Choose Dark for a dark editor. Inherit and Light both render the light theme.

Events

The Code Editor fires no events. Read {{ id.value }} from the action that needs it, for example a Save button's On Click.

Methods

Method

Params

Effect

Insert Text

Text

Inserts the text at the cursor. It does not replace the content.

Reset

Reset to Default

With Reset to Default on, restores the default value. With it off, clears the editor.

Exposed State

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

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 key

Type

Description

{{ id.content.input }}

object

The 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.content.input }}), not written back to your data source. Save explicitly on On Change.

Block

Relationship

Image

Display a single image without the sandbox overhead of an iframe.

Media

Display images, video and other media without the sandbox overhead of an iframe.

Form

Collects values from users; use instead of Schema Editor when collecting data, not designing schemas.

Text Area

Plain multi-line text input for prose — use instead of Code Editor when the content isn't code.

FAQs

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 receive data from an embedded page in my Iframe?

When the embedded page calls window.parent.postMessage(data, '*'), the Iframe block fires its On Message Received event. The message is available at {{ id.events.onMessageReceived.message }} — use that event to update page variables or call automations in response. The Iframe block has no methods, so it cannot send messages into the embedded page.

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 as the user types. The Code Editor fires no events, so bind a Save button's On Click to read {{ codeEditor1.value }} and pass it to your data source. To set content from an action, use the Insert Text or Reset method. If you bind the Default value to a changing expression, each change replaces the editor content and discards unsaved edits.

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.content.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.