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, callback?: (result: unknown, error: Error) => void): Promise<unknown>

Parameters:

ParameterTypeDescription
worldIdnumberThe id of the isolated world to run the scripts in.
scriptsElectronWebSource[]The scripts to evaluate.
userGesture?booleanWhether to treat the evaluation as being triggered by a user gesture.
callback?(result: unknown, error: Error) => voidCalled 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).