First iFrame

One way for iframes to communicate with each other is by using the postMessage API stackoverflow . This allows you to send messages between windows or iframes even if they have different domains stackoverflow .

To send a message from one iframe to another, you can dispatch an Event from the first iframe to its parent window that notifies it that the iframe is loaded. The parent window can then listen for this event and reply to the iframe with a message. The second iframe can also listen for this message and act accordingly stackoverflow .

The following code – our first iframe – uses @thi.ng/rdom to return the document Location as a string, which is rendered in the div#output of our Static Import Snippet (js-snippet frame).

~

Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible. github

~

import { $compile } from "https://cdn.skypack.dev/@thi.ng/rdom";

JS-Snippet Frame:

//wiki.ralfbarkow.ch/assets/pages/js-snippet-template/importjs.html HEIGHT 128

Return the document location as a string (see js-snippet frame above for the output):

$compile( ["p", {}, document.URL] ).mount(document.getElementById("output"));

See Document.URL mdn (docs)

Compare the document.URL returned by the js-snippet frame with the watch expression – the document.URL of the Lineup – in the following screenshot. They differ. Why?

document.URL

A Plugin can access the entire Lineup while an HTML script in a Frame plugin can only see what the Frame plugin provides. Plugins can announce that they have data ready to be read by adding a “something-source” class to their <div> in the lineup. Most plugins look for this class instead of parsing whole pages.

The Grep plugin [⇒ About Grep PluginAbout Grep Markup] and Site Survey Probes [⇒ Site Survey FactoryCatalog of Survey Probes] are exceptions; however, Site Survey Probes cannot see the lineup and must read the entire Sitemap [⇒ Wiki Sitemap]. matrix

The Graph Plugin exposes parent-child relationships by "graph-source" annotation. The Frame plugin can see this information because it follows the "something-source" convention and makes what it finds available to the html scripts it contains. matrix

~

We send a message to the Frame asking it to send us info about the page surrounding it. mdn

The Frame plugin renders an html page within a wiki page. More important, it also runs any javascript present within a sandbox where there is little opportunity to do harm. The Frame plugin can interact with the lineup on behalf of sandboxed javascript.

The Frame plugin replies with source data from other plugins in the lineup. In this example we look for "marker-source" offered by the Map plugin and a few others.