On this page

webview

Functions and constants for interacting with webview APIs

Functions

webview.create(callback: (...args: unknown[]) => unknown)

Creates a webview instance. It can show HTML pages as well as evaluate Javascript. The view remains hidden until the first call. There can exist a maximum of 4 webviews at the same time. On iOS, the callback will never get a webview.CALLBACK_RESULT_EVAL_ERROR, due to the iOS SDK implementation."

Parameters

  • callback: (...args: unknown[]) => unknown — A callback which receives info about finished requests taking the following parameters:

webview.destroy(webview_id: number)

Destroys an instance of a webview.

Parameters

  • webview_id: number — The webview id (returned by the webview.create() call)

webview.open_raw(webview_id: number, html: string, options: Record<string | number, unknown>)

Opens a web page in the webview, using HTML data. Once the request is done, the callback (registered in webview.create()) is invoked.

Parameters

  • webview_id: number — The webview id
  • html: string — The HTML data to display
  • options: Record<string | number, unknown> — A table of options for the request. See webview.open()

webview.eval(webview_id: number, code: string)

Evaluates JavaScript within the context of the currently loaded page (if any). Once the request is done, the callback (registered in webview.create()) is invoked. The callback will get the result in the data["result"] field.

Parameters

  • webview_id: number — The webview id
  • code: string — The JavaScript code to evaluate

webview.set_transparent(webview_id: number, transparent: boolean)

Set transparency of webview background

Parameters

  • webview_id: number — The webview id
  • transparent: boolean — If true, the webview background becomes transparent, otherwise opaque.

webview.set_visible(webview_id: number, visible: number)

Shows or hides a webview

Parameters

  • webview_id: number — The webview id
  • visible: number — If 0, hides the webview. If non zero, shows the view

webview.is_visible(webview_id: number)

Returns the visibility state of the webview.

Parameters

  • webview_id: number — The webview id

webview.set_position(webview_id: number, x: number, y: number, width: number, height: number)

Sets the position and size of the webview

Parameters

  • webview_id: number — The webview id
  • x: number — The x position of the webview
  • y: number — The y position of the webview
  • width: number — The width of the webview (-1 to match screen width)
  • height: number — The height of the webview (-1 to match screen height)