Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.6e

Application v 6.3a

  

 

Chapter Twenty-oneWebView Interface (continued)

JavaScriptRun Function

Overview

The JavaScriptRun function injects JavaScript into a WebView and returns a JavaScript Object handle.

Syntax/Parameters

Syntax

handle = JavaScriptRun ( handle hWVO, string code | wstring code, [boolean wait] );

Parameters

hWVO

A handle specifying a WebView Object.

code

A string or wstring specifying JavaScript code to execute.

wait

An optional boolean flag specifying whether to wait for the JavaScript to complete. The default value is FALSE.

Return Value

On success, a handle specifying a JavaScript Object or NULL_HANDLE on failure. Use the IsError or GetLastError function to determine if an error occurred and the nature of the error.

Remarks

The JavaScript code is injected into the WebView and executed immediately. The injected code can interact with the DOM but is subject to the active page’s content security policy. Because of this is, it is not recommended to write a script that injects more JavaScript on to the page unless the site actively allows such.

The WebView object can inject JavaScript before the page is finished loading so developers should design their script to handle cases where the DOM may be in flux. Any data returned by the JavaScript code can be retrieved using the JavaScriptGetJSON or JavaScriptGetRaw functions. If the script throws a JavaScript exception the returned value will be “null”.

If the wait parameter is set to true the Legato script will block until the JavaScript is completed. Using this option while inside a callback may result in a deadlock. Developers can use the JavaScriptIsComplete function to test if the script has completely executed including any JavaScript promises. Any events added by the script will continue to be in effect unless removed by other scripts.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Page revised 2025-10-20