On this page
webview
Functions and constants for interacting with webview APIs
Functions
webview.create(callback: (...args: unknown[]) => unknown)webview.destroy(webview_id: number)webview.open_raw(webview_id: number, html: string, options: Record<string | number, unknown>)webview.eval(webview_id: number, code: string)webview.set_transparent(webview_id: number, transparent: boolean)webview.set_visible(webview_id: number, visible: number)webview.is_visible(webview_id: number)webview.set_position(webview_id: number, x: number, y: number, width: number, height: number)
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 thewebview.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 idhtml:string— The HTML data to displayoptions:Record<string | number, unknown>— A table of options for the request. Seewebview.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 idcode: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 idtransparent:boolean— Iftrue, 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 idvisible:number— If0, 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 idx:number— The x position of the webviewy:number— The y position of the webviewwidth:number— The width of the webview (-1 to match screen width)height:number— The height of the webview (-1 to match screen height)