Skip to content

ElectronWebContents.once method

ElectronWebContents › once

Unofficial

Registers a one-time listener for the before-input-event event.

Signature:

once(event: "before-input-event", listener: (event: ElectronEvent, input: ElectronInput) => void): this

Parameters:

ParameterTypeDescription
event"before-input-event"The event name.
listener(event: ElectronEvent, input: ElectronInput) => voidCalled when the before-input-event event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the blur event.

Signature:

once(event: "blur", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"blur"The event name.
listener(...args: unknown[]) => voidCalled when the blur event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the certificate-error event.

Signature:

once(event: "certificate-error", listener: (event: ElectronEvent, url: string, error: string, certificate: ElectronCertificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => void): this

Parameters:

ParameterTypeDescription
event"certificate-error"The event name.
listener(event: ElectronEvent, url: string, error: string, certificate: ElectronCertificate, callback: (isTrusted: boolean) => void, isMainFrame: boolean) => voidCalled when the certificate-error event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the console-message event.

Signature:

once(event: "console-message", listener: (event: ElectronEvent, level: number, message: string, line: number, sourceId: string) => void): this

Parameters:

ParameterTypeDescription
event"console-message"The event name.
listener(event: ElectronEvent, level: number, message: string, line: number, sourceId: string) => voidCalled when the console-message event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the context-menu event.

Signature:

once(event: "context-menu", listener: (event: ElectronEvent, params: ElectronContextMenuParams) => void): this

Parameters:

ParameterTypeDescription
event"context-menu"The event name.
listener(event: ElectronEvent, params: ElectronContextMenuParams) => voidCalled when the context-menu event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the crashed event.

Signature:

once(event: "crashed", listener: (event: ElectronEvent, killed: boolean) => void): this

Parameters:

ParameterTypeDescription
event"crashed"The event name.
listener(event: ElectronEvent, killed: boolean) => voidCalled when the crashed event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the cursor-changed event.

Signature:

once(event: "cursor-changed", listener: (event: ElectronEvent, type: string, image: ElectronNativeImage, scale: number, size: ElectronSize, hotspot: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
event"cursor-changed"The event name.
listener(event: ElectronEvent, type: string, image: ElectronNativeImage, scale: number, size: ElectronSize, hotspot: ElectronPoint) => voidCalled when the cursor-changed event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the destroyed event.

Signature:

once(event: "destroyed", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"destroyed"The event name.
listener(...args: unknown[]) => voidCalled when the destroyed event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the devtools-closed event.

Signature:

once(event: "devtools-closed", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"devtools-closed"The event name.
listener(...args: unknown[]) => voidCalled when the devtools-closed event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the devtools-focused event.

Signature:

once(event: "devtools-focused", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"devtools-focused"The event name.
listener(...args: unknown[]) => voidCalled when the devtools-focused event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the devtools-opened event.

Signature:

once(event: "devtools-opened", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"devtools-opened"The event name.
listener(...args: unknown[]) => voidCalled when the devtools-opened event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the devtools-reload-page event.

Signature:

once(event: "devtools-reload-page", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"devtools-reload-page"The event name.
listener(...args: unknown[]) => voidCalled when the devtools-reload-page event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-attach-webview event.

Signature:

once(event: "did-attach-webview", listener: (event: ElectronEvent, webContents: ElectronWebContents) => void): this

Parameters:

ParameterTypeDescription
event"did-attach-webview"The event name.
listener(event: ElectronEvent, webContents: ElectronWebContents) => voidCalled when the did-attach-webview event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-change-theme-color event.

Signature:

once(event: "did-change-theme-color", listener: (event: ElectronEvent, color: string | null) => void): this

Parameters:

ParameterTypeDescription
event"did-change-theme-color"The event name.
listener(event: ElectronEvent, color: string | null) => voidCalled when the did-change-theme-color event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-create-window event.

Signature:

once(event: "did-create-window", listener: (window: ElectronBrowserWindow, details: ElectronDidCreateWindowDetails) => void): this

Parameters:

ParameterTypeDescription
event"did-create-window"The event name.
listener(window: ElectronBrowserWindow, details: ElectronDidCreateWindowDetails) => voidCalled when the did-create-window event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-fail-load event.

Signature:

once(event: "did-fail-load", listener: (event: ElectronEvent, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-fail-load"The event name.
listener(event: ElectronEvent, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-fail-load event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-fail-provisional-load event.

Signature:

once(event: "did-fail-provisional-load", listener: (event: ElectronEvent, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-fail-provisional-load"The event name.
listener(event: ElectronEvent, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-fail-provisional-load event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-finish-load event.

Signature:

once(event: "did-finish-load", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"did-finish-load"The event name.
listener(...args: unknown[]) => voidCalled when the did-finish-load event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-frame-finish-load event.

Signature:

once(event: "did-frame-finish-load", listener: (event: ElectronEvent, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-frame-finish-load"The event name.
listener(event: ElectronEvent, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-frame-finish-load event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-frame-navigate event.

Signature:

once(event: "did-frame-navigate", listener: (event: ElectronEvent, url: string, httpResponseCode: number, httpStatusText: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-frame-navigate"The event name.
listener(event: ElectronEvent, url: string, httpResponseCode: number, httpStatusText: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-frame-navigate event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-navigate event.

Signature:

once(event: "did-navigate", listener: (event: ElectronEvent, url: string, httpResponseCode: number, httpStatusText: string) => void): this

Parameters:

ParameterTypeDescription
event"did-navigate"The event name.
listener(event: ElectronEvent, url: string, httpResponseCode: number, httpStatusText: string) => voidCalled when the did-navigate event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-navigate-in-page event.

Signature:

once(event: "did-navigate-in-page", listener: (event: ElectronEvent, url: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-navigate-in-page"The event name.
listener(event: ElectronEvent, url: string, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-navigate-in-page event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-redirect-navigation event.

Signature:

once(event: "did-redirect-navigation", listener: (event: ElectronEvent, url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-redirect-navigation"The event name.
listener(event: ElectronEvent, url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-redirect-navigation event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-start-loading event.

Signature:

once(event: "did-start-loading", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"did-start-loading"The event name.
listener(...args: unknown[]) => voidCalled when the did-start-loading event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-start-navigation event.

Signature:

once(event: "did-start-navigation", listener: (event: ElectronEvent, url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"did-start-navigation"The event name.
listener(event: ElectronEvent, url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the did-start-navigation event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the did-stop-loading event.

Signature:

once(event: "did-stop-loading", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"did-stop-loading"The event name.
listener(...args: unknown[]) => voidCalled when the did-stop-loading event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the dom-ready event.

Signature:

once(event: "dom-ready", listener: (event: ElectronEvent) => void): this

Parameters:

ParameterTypeDescription
event"dom-ready"The event name.
listener(event: ElectronEvent) => voidCalled when the dom-ready event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the enter-html-full-screen event.

Signature:

once(event: "enter-html-full-screen", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"enter-html-full-screen"The event name.
listener(...args: unknown[]) => voidCalled when the enter-html-full-screen event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the focus event.

Signature:

once(event: "focus", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"focus"The event name.
listener(...args: unknown[]) => voidCalled when the focus event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the found-in-page event.

Signature:

once(event: "found-in-page", listener: (event: ElectronEvent, result: ElectronResult) => void): this

Parameters:

ParameterTypeDescription
event"found-in-page"The event name.
listener(event: ElectronEvent, result: ElectronResult) => voidCalled when the found-in-page event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the frame-created event.

Signature:

once(event: "frame-created", listener: (event: ElectronEvent, details: ElectronFrameCreatedDetails) => void): this

Parameters:

ParameterTypeDescription
event"frame-created"The event name.
listener(event: ElectronEvent, details: ElectronFrameCreatedDetails) => voidCalled when the frame-created event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the input-event event.

Signature:

once(event: "input-event", listener: (event: ElectronEvent, inputEvent: ElectronAnyInputEvent) => void): this

Parameters:

ParameterTypeDescription
event"input-event"The event name.
listener(event: ElectronEvent, inputEvent: ElectronAnyInputEvent) => voidCalled when the input-event event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the ipc-message event.

Signature:

once(event: "ipc-message", listener: (event: ElectronEvent, channel: string, ...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"ipc-message"The event name.
listener(event: ElectronEvent, channel: string, ...args: unknown[]) => voidCalled when the ipc-message event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the ipc-message-sync event.

Signature:

once(event: "ipc-message-sync", listener: (event: ElectronEvent, channel: string, ...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"ipc-message-sync"The event name.
listener(event: ElectronEvent, channel: string, ...args: unknown[]) => voidCalled when the ipc-message-sync event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the leave-html-full-screen event.

Signature:

once(event: "leave-html-full-screen", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"leave-html-full-screen"The event name.
listener(...args: unknown[]) => voidCalled when the leave-html-full-screen event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the login event.

Signature:

once(event: "login", listener: (event: ElectronEvent, authenticationResponseDetails: ElectronAuthenticationResponseDetails, authInfo: ElectronAuthInfo, callback: (username?: string | undefined, password?: string | undefined) => void) => void): this

Parameters:

ParameterTypeDescription
event"login"The event name.
listener(event: ElectronEvent, authenticationResponseDetails: ElectronAuthenticationResponseDetails, authInfo: ElectronAuthInfo, callback: (username?: string | undefined, password?: string | undefined) => void) => voidCalled when the login event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the media-paused event.

Signature:

once(event: "media-paused", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"media-paused"The event name.
listener(...args: unknown[]) => voidCalled when the media-paused event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the media-started-playing event.

Signature:

once(event: "media-started-playing", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"media-started-playing"The event name.
listener(...args: unknown[]) => voidCalled when the media-started-playing event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the new-window event.

Signature:

once(event: "new-window", listener: (event: ElectronNewWindowWebContentsEvent, url: string, frameName: string, disposition: "new-window" | "background-tab" | "default" | "foreground-tab" | "other" | "save-to-disk", options: BrowserWindowConstructorOptions, additionalFeatures: string[], referrer: ElectronReferrer, postBody: ElectronPostBody) => void): this

Parameters:

ParameterTypeDescription
event"new-window"The event name.
listener(event: ElectronNewWindowWebContentsEvent, url: string, frameName: string, disposition: "new-window" | "background-tab" | "default" | "foreground-tab" | "other" | "save-to-disk", options: BrowserWindowConstructorOptions, additionalFeatures: string[], referrer: ElectronReferrer, postBody: ElectronPostBody) => voidCalled when the new-window event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the page-favicon-updated event.

Signature:

once(event: "page-favicon-updated", listener: (event: ElectronEvent, favicons: string[]) => void): this

Parameters:

ParameterTypeDescription
event"page-favicon-updated"The event name.
listener(event: ElectronEvent, favicons: string[]) => voidCalled when the page-favicon-updated event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the page-title-updated event.

Signature:

once(event: "page-title-updated", listener: (event: ElectronEvent, title: string, explicitSet: boolean) => void): this

Parameters:

ParameterTypeDescription
event"page-title-updated"The event name.
listener(event: ElectronEvent, title: string, explicitSet: boolean) => voidCalled when the page-title-updated event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the paint event.

Signature:

once(event: "paint", listener: (event: ElectronEvent, dirtyRect: ElectronRectangle, image: ElectronNativeImage) => void): this

Parameters:

ParameterTypeDescription
event"paint"The event name.
listener(event: ElectronEvent, dirtyRect: ElectronRectangle, image: ElectronNativeImage) => voidCalled when the paint event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the plugin-crashed event.

Signature:

once(event: "plugin-crashed", listener: (event: ElectronEvent, name: string, version: string) => void): this

Parameters:

ParameterTypeDescription
event"plugin-crashed"The event name.
listener(event: ElectronEvent, name: string, version: string) => voidCalled when the plugin-crashed event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the preferred-size-changed event.

Signature:

once(event: "preferred-size-changed", listener: (event: ElectronEvent, preferredSize: ElectronSize) => void): this

Parameters:

ParameterTypeDescription
event"preferred-size-changed"The event name.
listener(event: ElectronEvent, preferredSize: ElectronSize) => voidCalled when the preferred-size-changed event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the preload-error event.

Signature:

once(event: "preload-error", listener: (event: ElectronEvent, preloadPath: string, error: Error) => void): this

Parameters:

ParameterTypeDescription
event"preload-error"The event name.
listener(event: ElectronEvent, preloadPath: string, error: Error) => voidCalled when the preload-error event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the render-process-gone event.

Signature:

once(event: "render-process-gone", listener: (event: ElectronEvent, details: ElectronRenderProcessGoneDetails) => void): this

Parameters:

ParameterTypeDescription
event"render-process-gone"The event name.
listener(event: ElectronEvent, details: ElectronRenderProcessGoneDetails) => voidCalled when the render-process-gone event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the responsive event.

Signature:

once(event: "responsive", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"responsive"The event name.
listener(...args: unknown[]) => voidCalled when the responsive event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the select-bluetooth-device event.

Signature:

once(event: "select-bluetooth-device", listener: (event: ElectronEvent, devices: ElectronBluetoothDevice[], callback: (deviceId: string) => void) => void): this

Parameters:

ParameterTypeDescription
event"select-bluetooth-device"The event name.
listener(event: ElectronEvent, devices: ElectronBluetoothDevice[], callback: (deviceId: string) => void) => voidCalled when the select-bluetooth-device event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the select-client-certificate event.

Signature:

once(event: "select-client-certificate", listener: (event: ElectronEvent, url: string, certificateList: ElectronCertificate[], callback: (certificate: ElectronCertificate) => void) => void): this

Parameters:

ParameterTypeDescription
event"select-client-certificate"The event name.
listener(event: ElectronEvent, url: string, certificateList: ElectronCertificate[], callback: (certificate: ElectronCertificate) => void) => voidCalled when the select-client-certificate event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the unresponsive event.

Signature:

once(event: "unresponsive", listener: (...args: unknown[]) => void): this

Parameters:

ParameterTypeDescription
event"unresponsive"The event name.
listener(...args: unknown[]) => voidCalled when the unresponsive event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the update-target-url event.

Signature:

once(event: "update-target-url", listener: (event: ElectronEvent, url: string) => void): this

Parameters:

ParameterTypeDescription
event"update-target-url"The event name.
listener(event: ElectronEvent, url: string) => voidCalled when the update-target-url event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the will-attach-webview event.

Signature:

once(event: "will-attach-webview", listener: (event: ElectronEvent, webPreferences: WebPreferences, params: Record<string, string>) => void): this

Parameters:

ParameterTypeDescription
event"will-attach-webview"The event name.
listener(event: ElectronEvent, webPreferences: WebPreferences, params: Record<string, string>) => voidCalled when the will-attach-webview event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the will-navigate event.

Signature:

once(event: "will-navigate", listener: (event: ElectronEvent, url: string) => void): this

Parameters:

ParameterTypeDescription
event"will-navigate"The event name.
listener(event: ElectronEvent, url: string) => voidCalled when the will-navigate event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the will-prevent-unload event.

Signature:

once(event: "will-prevent-unload", listener: (event: ElectronEvent) => void): this

Parameters:

ParameterTypeDescription
event"will-prevent-unload"The event name.
listener(event: ElectronEvent) => voidCalled when the will-prevent-unload event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the will-redirect event.

Signature:

once(event: "will-redirect", listener: (event: ElectronEvent, url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this

Parameters:

ParameterTypeDescription
event"will-redirect"The event name.
listener(event: ElectronEvent, url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => voidCalled when the will-redirect event is emitted.

Returns: thisThis web contents instance.


Unofficial

Registers a one-time listener for the zoom-changed event.

Signature:

once(event: "zoom-changed", listener: (event: ElectronEvent, zoomDirection: "in" | "out") => void): this

Parameters:

ParameterTypeDescription
event"zoom-changed"The event name.
listener(event: ElectronEvent, zoomDirection: "in" | "out") => voidCalled when the zoom-changed event is emitted.

Returns: thisThis web contents instance.