Web content script API
A web content object shows your own HTML in a sandboxed frame. Inside that frame the HTML gets one object, eax, and the data-tag attribute. They show live values. They cannot write a tag, and they cannot reach the operator’s page. This page lists what they do.
The frame
Section titled “The frame”| Sandbox | allow-scripts only: the frame has its own opaque origin, with no access to the operator’s page, session, cookies or browser storage. |
| Content policy | Inline scripts and styles only. No requests (connect-src 'none'), no forms, no nested frames, no workers, no plugins. Images only when embedded in the HTML (data: or blob:), fonts only as data:; video and audio sources are blocked. No address outside the frame is loaded, of another server or of this one. The server’s own stylesheet (that one file only) is linked, so the studio’s classes can be used. |
| Leaving the frame | The frame may not open another address. A script that sets location, a meta refresh or a followed link stops it: values stop at unload, and at its next load (or after 1.5 s) it is blanked to an empty document showing This web content tried to open another address and was stopped. It stays stopped until the screen is opened again. The first request of that navigation has already left the browser. |
| Connections | Before the HTML’s script runs, WebRTC connections are refused and resource-hint links (dns-prefetch, preconnect, prefetch, prerender) are removed from the HTML. A hint a script inserts later still opens its connection when it is inserted. |
| Messages | The frame receives values from its own page only. Nothing it sends can write a tag or call the page: it can only ask for values. |
| Errors | A script error, also one thrown inside an eax.on callback, is shown in a red bar at the bottom of the frame: Script error: <message> (line n). |
| Iframe URL | When the object has an iframe URL, that page is shown instead of the HTML. It gets no eax and no tag values. |
data-tag elements
Section titled “data-tag elements”An element with data-tag shows the tag’s value as its text, with each new value.
<span data-tag="Plant/Processing/Tank1/Level" data-decimals="1" data-unit="%"></span><span data-tag="Plant/Processing/P101/Running" data-on="RUN" data-off="STOP"></span>| Attribute | What it does |
|---|---|
data-tag |
The tag path. |
data-decimals |
A number value is shown with this many decimals. |
data-unit |
Text added after the value, with a space. |
data-on, data-off |
The value is shown as an on or off text: on when it is true or a number above 0. When only one of them is set, the other one is ON or OFF. |
data-quality |
Set by the frame on each value: good, uncertain or bad. Bad text is red and Uncertain text amber. Your own CSS can use the attribute too. |
A boolean without data-on / data-off shows TRUE or FALSE. A value that is empty, null or not yet received shows a dash (—).
| Function | What it does |
|---|---|
eax.on(path, (value, tag) => ...) |
Calls the function with each new value of the tag, and at once when a value is already there. tag is the value object below. The tag is asked for when it is not one the frame already receives. |
eax.value(path) |
The tag’s last value, or undefined when the frame has none. It does not ask for the tag: use it for tags of the object’s Tags list, or after eax.on. |
eax.tag(path) |
The last value object, {value, quality, good, timestamp}, or undefined. It does not ask for the tag either. |
eax.scan() |
Looks for data-tag elements again. Call it after a script adds such elements. |
The value object:
| Member | |
|---|---|
value |
The value, null when there is none. |
quality |
good, uncertain or bad. Anything that is not Good or Uncertain is bad. |
good |
true when the quality is good. |
timestamp |
The value’s time, as the server sent it, or null. |
Inline scripts. A <script> in the middle of the HTML runs before the frame’s own runtime, which comes after the content. Such a script can still call eax.on and eax.scan where it stands: the calls are queued and taken over when the runtime starts. eax.value and eax.tag answer undefined until then.
The Tags list
Section titled “The Tags list”The object’s Tags list, in the inspector’s Properties tab, names the tags its HTML reads (saved as props.tags, an array of paths). These tags are subscribed with the screen wherever it is shown: a page, a popup, an inner screen (also one swapped in by a script) or a dock. The frame receives their values without asking, so data-tag elements, eax.on and eax.value have them from the start.
| Case | What is subscribed with the screen |
|---|---|
| The object has a Tags list | The list. Paths its HTML names literally but the list lacks are named under the list, each with Add. |
| A screen saved before the list existed (no list) | The paths its HTML names literally, shown as detected. Use these tags keeps them as the object’s list. |
| An iframe URL is set | Nothing: that page receives no tag values. |
Found literally means: a data-tag attribute, and eax.on, eax.value or eax.tag called with a quoted path (eax.on('Plant/Line1/Speed', ...)). The HTML is read as text, never run. A path built while the HTML runs (eax.on(prefix + name, ...), a template string with ${...}) cannot be found: put it in the list. A path with a space, <, >, a quote or a backtick is not taken.
A path the HTML asks for at run time that is not in the list is held for as long as the object is shown on the page, then released. It gets its value after the server answers, not with the screen.
Rights. The list changes nothing in the read rights: the server checks every subscribed tag against the operator’s read right, and a tag the operator may not read shows Bad.
Where-used and rename. Find where used shows the tags of the list (and the HTML’s data-tag paths) as read by the object, and renaming a tag with Find and replace rewrites the list.
Images and fonts
Section titled “Images and fonts”Embed every image and font in the HTML, as a data: URL:
<img alt="P-101" src="data:image/png;base64,iVBORw0KGgo...">An <img src="https://...">, an image of this server by address (/static/...), a web font from another server, a <video> or <audio> source and an outside <script src> are not loaded. Content that used them before this release shows without them. The policy exists because an image address can carry any value the script sees to the server it names.
Limits
Section titled “Limits”- At most 500 tags per object (the list and the paths asked for at run time together), each path at most 512 characters.
- The first 256 KB of the HTML are searched for literal paths.
See also
Section titled “See also”- Web content: the object’s properties.
- How live values reach screens
- Screen scripting API: the
system.*functions of screen scripts, which run in another sandbox.