Skip to content

ElectronWebFrame.executeJavaScript method

ElectronWebFrame › executeJavaScript

Unofficial

Evaluates code in the page. In the browser window some HTML APIs like requestFullScreen can only be invoked by a gesture from the user. Setting userGesture to true will remove this limitation.

Signature:

executeJavaScript(code: string, userGesture?: boolean, callback?: (result: unknown, error: Error) => void): Promise<unknown>

Parameters:

ParameterTypeDescription
codestringThe code 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 throws or results in a rejected promise. Modeled with unknown (the upstream type is any).