Lynx

<frame>

A page element similar to HTML's <iframe>, which can embed a Lynx page into the current page.

Usage Guide

The following is an example of a main page loading an embedded page via the <frame> element.

  • The main page passes initData and globalProps to the embedded page through the data and global-props attributes.
  • The main page listens for the embedded page loading status via the bindload event, and can use bindloadmetrics to receive loading metrics.

Main Page

Embedded Page

Tip

The <frame> element was introduced in

3.4. To use this element, the Lynx dependency version must be upgraded to
3.4
or higher.

Tip

Starting from

3.8, auto-width and auto-height can make <frame> follow the embedded page's content size. If automatic sizing is disabled, or if you are using an earlier version, you still need to manually set the frame width and height. Before the first content size is initialized,
3.9
and later can use preset-width and preset-height to set the preset size.

Attributes

auto-height

Android
iOS
3.8
// @defaultValue: false
'auto-height'?: boolean;

Lets the frame height follow the embedded Lynx page’s content height. When enabled, the embedded page can report its content size, and the frame uses that value as its measured height.

auto-width

Android
iOS
3.8
// @defaultValue: false
'auto-width'?: boolean;

Lets the frame width follow the embedded Lynx page’s content width. When enabled, the embedded page can report its content size, and the frame uses that value as its measured width.

data

Android
iOS
3.4
data?: Record<string, unknown>;

Passes data to the nested Lynx page within the frame.

enable-multi-async-thread

Android
iOS
3.9
// @defaultValue: false
'enable-multi-async-thread'?: boolean;

Overrides whether the embedded Lynx page uses multiple asynchronous threads. When omitted, the frame inherits the host setting.

global-props

Android
iOS
3.6
'global-props'?: Record<string, unknown>;

Passes globalProps to the Lynx page embedded in the frame. The embedded page can read it via lynx.__globalProps .

preset-height

Android
iOS
3.9
'preset-height'?: `${number}px` | `${number}rpx`;

Sets the preset height used before the embedded Lynx page receives an initialized content rect.

preset-width

Android
iOS
3.9
'preset-width'?: `${number}px` | `${number}rpx`;

Sets the preset width used before the embedded Lynx page receives an initialized content rect.

src

Android
iOS
3.4
src: string;

Sets the loading path for the frame resource.

Events

Frontend can bind corresponding event callbacks to listen for runtime behaviors of the element, as shown below.

bindload

Android
iOS
3.6
bindload = (e: FrameLoadEvent) => {};
FieldTypeOptionalDefaultPlatformsSinceDescription
statusCodenumberNo
Android
iOS
3.6
3.6Frame loaded status code.
statusMessagestringNo
Android
iOS
3.6
3.6Frame loaded status message.
urlstringNo
Android
iOS
3.6
3.6The loaded url of the frame.

Bind frame load event callback.

bindloadmetrics

Android
iOS
3.9
bindloadmetrics = (e: FrameLoadMetricsEvent) => {};
FieldTypeOptionalDefaultPlatformsSinceDescription
entryFrameLoadMetricsEntryNo
Android
iOS
3.9
3.9The raw loadBundle performance entry emitted by the embedded Lynx page.
modestringNo
Android
iOS
3.9
3.9The frame loading mode.
urlstringNo
Android
iOS
3.9
3.9The loaded url of the frame.

Bind frame load metrics event callback.

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.