Iframe Block
Block: iframeCommunity Edition+Introduction
The IFrame block allows embedding external web pages or content into the current page. Users can integrate external applications seamlessly by configuring a URL or directly inserting HTML code. With HTML, users can flexibly customize content to meet specific display needs, making it ideal for customized scenarios. This approach enables loading external resources without redirection, enhancing user experience and page interactivity.
Installation
It's a built-in plugin, no installation is required.
Adding Blocks

Configure the URL or Html to directly embed the external application.

Template engine
String Template
The default template engine.
Handlebars

For more information, refer to the Handlebars template documentation.
Passing Variables
HTML Support for Variable Parsing
Support for Selecting Variables from the Variable Selector in the Current Block Context


Support for Injecting Variables into the Application and Using Them through Code
You can also inject custom variables into the application through code and use them in HTML. For example, creating a dynamic calendar application using Vue 3 and Element Plus:

Example: A simple calendar component created with React and Ant Design (antd), using dayjs to handle dates

URL supports variables

For more information on variables, refer to the Variables documentation.
Creating Iframes with JS Blocks (NocoBase 2.0)
In NocoBase 2.0, you can use JS blocks to dynamically create iframes with more control. This approach provides better flexibility for customizing iframe behavior and styling.
Basic Example
Create a JS block and use the following code to create an iframe:
Key Points
- ctx.element: The DOM element of the current JS block container
- sandbox attribute: Controls security restrictions for the iframe content
allow-scripts: Allows the iframe to execute scriptsallow-same-origin: Allows the iframe to access its own origin
- replaceChildren(): Replaces all children of the container with the iframe
Advanced Example with Loading State
You can enhance the iframe creation with loading states and error handling:
Security Considerations
When using iframes, consider the following security best practices:
- Use HTTPS: Always load iframe content over HTTPS when possible
- Restrict Sandbox Permissions: Only enable necessary sandbox permissions
- Content Security Policy: Configure appropriate CSP headers
- Same-Origin Policy: Be aware of cross-origin restrictions
- Trusted Sources: Only load content from trusted domains

