Skip to content

ElectronWebFrame.executeJavaScriptInIsolatedWorld method

ElectronWebFrame › executeJavaScriptInIsolatedWorld

Unofficial

Works like executeJavaScript but evaluates scripts in an isolated context. When the execution of a script fails, the returned promise will not reject and the result would be undefined.

Signature:

executeJavaScriptInIsolatedWorld(worldId: number, scripts: ElectronWebSource[], userGesture?: boolean | undefined, callback?: ((result: unknown, error: Error) => void) | undefined): Promise<unknown>

Parameters:

ParameterTypeDescription
worldIdnumberThe id of the isolated world to run the scripts in.
scriptsElectronWebSource[]The scripts to evaluate.
userGesture?boolean | undefinedWhether to treat the evaluation as being triggered by a user gesture.
callback?((result: unknown, error: Error) => void) | undefinedCalled with the result of the executed code. Modeled with unknown (the upstream result type is any).

Returns: Promise<unknown>A promise that resolves with the result of the executed code, or is rejected if execution could not start. Modeled with unknown (the upstream type is any).