Skip to content
M2O Scripting APIScripting reference
Global objectClient APIGenerated

Web

const Web: object

Defined in: client/api.d.ts:2143

Client-only, resource-owned CEF web-view API exposed as the global Web.

createView(url, options?): number

Creates an origin-locked web view owned by the calling resource.

string

Resource-relative URL or allowed absolute URL loaded into the view.

Optional initial pixel geometry, stacking, visibility, and focus settings.

boolean

number

boolean

number

number

number

number

number

Numeric view ID used by the remaining Web methods.

destroyView(viewId): boolean

Destroys an owned view and removes all of its script event handlers.

number

Owned view identifier.

boolean

True when a view was destroyed.

emit(viewId, eventName, payload?): boolean

Dispatches a CustomEvent into an owned view.

number

Owned view identifier.

string

CustomEvent name dispatched in the page.

unknown

Optional JSON-serializable event detail.

boolean

True when the dispatch script was queued.

focusView(viewId, focused?): boolean

Changes input focus for an owned view.

number

Owned view identifier.

boolean

Whether the view captures keyboard and mouse input; defaults to true.

boolean

True when the view exists and focus was updated.

getScreenSize(): object

Returns the current client viewport size.

object

Width and height in physical pixels.

height: number

width: number

hideView(viewId): boolean

Hides an owned view.

number

Owned view identifier.

boolean

True when the view exists and was updated.

isViewVisible(viewId): boolean

Checks whether an owned view is currently visible.

number

Owned view identifier.

boolean

False for missing or unowned views.

loadURL(viewId, url): boolean

Navigates a view and replaces its allowed origin with the new URL’s origin.

number

Owned view identifier.

string

New resource-relative or allowed absolute URL.

boolean

True when navigation was requested.

off(viewId, eventName, handler?): boolean

Removes page-event handlers from an owned view.

number

Owned view identifier.

string

Page-to-script event name.

WebEventHandler

Optional exact callback; omitting it removes every matching handler owned by the resource.

boolean

True when at least one handler was removed.

on(viewId, eventName, handler): void

Registers a handler for an event emitted by an owned same-origin page.

number

Owned view identifier.

string

Page-to-script event name.

WebEventHandler

Resource-owned callback invoked by the view’s callEvent bridge.

void

resizeView(viewId, width, height): boolean

Resizes an owned view’s viewport.

number

Owned view identifier.

number

New viewport width in pixels.

number

New viewport height in pixels.

boolean

True when the view exists and was resized.

setViewPosition(viewId, x, y): boolean

Moves an owned view on screen.

number

Owned view identifier.

number

New horizontal screen position in pixels.

number

New vertical screen position in pixels.

boolean

True when the view exists and was moved.

showView(viewId): boolean

Makes an owned view visible.

number

Owned view identifier.

boolean

True when the view exists and was updated.