Comment on page
Editing Pages with iFrames
An iframe (inline frame) is used to embed a document inside the current document. The embedded document can be from the same site, or a different site.
Framed documents are separate/distinct from the top-level tab. A separate “instance” of PixieBrix runs in each iframe.
The Page Editor works on the top-level frame of the tab. It cannot directly select/modify elements in the document embedded within an iframe.
In selection/placement mode, when part of the page is an iframe, PixieBrix will highlight the whole iframe on hover because to the Page Editor, the iframe is a single element:

The Page Editor element selector over an iframe: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
IFrames are distinct documents. To edit a document in an iframe with PixieBrix, you’ll edit the document and not the containing tab.
To extend a framed document with PixieBrix, you have two options:
- 1.Preferred: Open the framed document in its own tab and use the Page Editor
- 2.Use the Page Editor on the top-level tab, and manually write element selectors
- 1.Use the Chrome Dev Tools element selector
- 2.Select an element within the frame
- 3.Find the iframe ancestor element. It will have tag
<iframe>
and show a#document
sub node: - 4.Right click the
src
attribute value and click “Copy link address”. This will copy a link address to the clipboard (including the origin if thesrc
attribute does not already include it)
Not all framed pages can be opened in their own tab. Some documents are configured to re-direct if they detect they’re not running inside a frame
- 1.Find the URL of the iframe (see above)
- 2.Open a new tab and navigate to the document URL
- 3.Open the Page Editor and edit the page as usual
The Page Editor dynamically updates mods on the top-level tab. To run an updated mod in the iframed documents, you must Save the mod.
- 1.Find the URL of the iframe (see above)
- 2.Add the mod in the Page Editor
- 3.Modify the “Sites” to match the source of the framed document
- 4.Build the mod as normal, but manually write elements selectors. (Because the Page Editor cannot select elements in iframes)
- 5.Save the Mod
- 6.Right-click on the frame and select “Reload Frame” from the Chrome context menu:
- 7.Your Mod will run inside the framed document
To run a brick in the top-level frame on the page, set the Advanced Options > Target Tab/Frame to “Top-level Frame (top)”

Configuring a brick to run in the top-level frame
Configuring a brick to run in the top-level frame
To make data from an inline frame available to the Top-Level Frame, use the “Set Shared Page State” brick in conjunction with the Target Tab/Frame Setting
When the brick runs, it will set the value in the state of the Top-Level Frame.

Sending data from an inner frame to the top-level frame
Sending data from an inner frame to the top-level frame
PixieBrix does not currently support pushing data directly from a Top-Level Frame to an Inline Frame.
Instead, to transfer data from the Top-Level Frame to an Inline Frame, the Inline Frame must request/poll for the information from the Top-Level Frame.
To retrieve information from the Top-Level Frame, use Advanced Options > Target Tab/Frame for the brick.
For example, to extract the header from the Top-Level Frame using the Extract from Page brick:

Using Target Tab/Frame: Top-level Frame to extract information from the Top-Level Frame
Using Target Tab/Frame: Top-level Frame to extract information from the Top-Level Frame
The Inline Frame can also read from the Page State of the Top-Level Frame using the “Get Shared Page State Brick”.
An Inline Frame may be initialized prior to the Top-Level Frame being ready. Therefore, you must take extra steps to ensure that the data is available reliably.
Some common approaches are:
- If the data is loaded on page load: Use the "Wait for a DOM element” brick with Target Tab/Frame: Top-level Frame to wait for the information to be available
- If the data may change: Use an Interval Trigger as the Starter Brick to poll for data
- Use Wait/Sleep to provide an opportunity for the native page to load
This use case is advanced/special. You generally will not use the “Post Message to a Frame” brick unless you are instructed to by the host application’s documentation
Some Javascript applications listen for events from other frames to support events and data transfer. These applications use the Javascript Window postMessage API
To send a message to a frame on the page, use the “Post Message to a Frame” brick. The brick has the following options:
- selector: the iframe to message
- message: the message payload. The shape will depend on what the receiver/listener expects to receive
- targetOrigin: the origin (schema, hostname, port) of the intended recipient, or
*
not to validate the target frame’s origin. Used to prevent sending sensitive information to the wrong location

Example configuration of the “Post message to a frame” brick
Last modified 23d ago