# Wrapper (iframe sandbox) Links: [Home](../index.md) Creates isolated iframe environments for running sandboxed content. Used internally by heavy modules like PDF Reader, SVG Editor, and the Code Editor to prevent global namespace pollution. ## Loading the Module ```js Application.require("gadgets/wrapper").then(function (Wrapper) { // Wrapper is a constructor function }); ``` **Dependency:** `extensions/prototype` ## API ### `Wrapper(config)` Create a new sandboxed iframe. ```js var w = Wrapper({ base: true, header: '', code: '

Hello from iframe

' }); ``` **Config options:** | Option | Type | Default | Description | |---|---|---|---| | `base` | `boolean / string` | `true` | Set ``. `true` uses current page URL | | `header` | `string` | `''` | Extra HTML injected into `` | | `code` | `string` | `''` | HTML content for `` | ### Instance Methods | Method | Returns | Description | |---|---|---| | `node()` | `HTMLIFrameElement` | Get the iframe element | | `container()` | `HTMLBodyElement` | Get the iframe's `document.body` | | `document()` | `Document` | Get the iframe's `document` object | | `window()` | `Window` | Get the iframe's `window` object | | `whenLoaded()` | `Promise` | Resolves when the iframe is fully loaded | ## Use Cases ### Run untrusted HTML in a sandbox ```js Application.require("gadgets/wrapper").then(function (Wrapper) { var sandbox = Wrapper({ code: '

Waiting...