WebContents
Properties
A boolean
property that determines whether this page is muted.
A boolean
property that determines whether or not this WebContents will throttle animations and timers when the page becomes backgrounded. This also affects the Page Visibility API.
A WebContents | null
property that represents the of DevTools WebContents
associated with a given WebContents
.
A WebContents
instance that might own this WebContents
.
A WebFrameMain
property that represents the top frame of the page's frame hierarchy.
A NavigationHistory
used by this webContents.
A WebFrameMain
property that represents the frame that opened this WebContents, either with open(), or by navigating a link with a target attribute.
A number
property that determines the zoom factor for this web contents.
Functions
Adds the specified path to DevTools workspace. Must be used after DevTools creation:
Adjusts the current text selection starting and ending points in the focused frame by the given amounts. A negative amount moves the selection towards the beginning of the document, and a positive amount moves the selection towards the end of the document.
Begin subscribing for presentation events and captured frames, the callback
will be called with callback(image, dirtyRect)
when there is a presentation event.
Whether the browser can go forward to next web page.
Whether the web page can go to offset
.
Resolves with a NativeImage
Centers the current text selection in web page.
Clears the navigation history.
Closes the devtools.
Copy the image at the given position to the clipboard.
Disable device emulation enabled by webContents.enableDeviceEmulation
.
Initiates a download of the resource at url
without navigating. The will-download
event of session
will be triggered.
Enable device emulation with the given parameters.
End subscribing for frame presentation events.
A promise that resolves with the result of the executed code or is rejected if the result of the code is a rejected promise.
A promise that resolves with the result of the executed code or is rejected if the result of the code is a rejected promise.
The request id used for the request.
Forcefully terminates the renderer process that is currently hosting this webContents
. This will cause the render-process-gone
event to be emitted with the reason=killed || reason=crashed
. Please note that some webContents share renderer processes and therefore calling this method may also crash the host process for other webContents as well.
Information about all Shared Workers.
whether or not this WebContents will throttle animations and timers when the page becomes backgrounded. This also affects the Page Visibility API.
the current title of the DevTools window. This will only be visible if DevTools is opened in undocked
or detach
mode.
If offscreen rendering is enabled returns the current frame rate.
The identifier of a WebContents stream. This identifier can be used with navigator.mediaDevices.getUserMedia
using a chromeMediaSource
of tab
. The identifier is restricted to the web contents that it is registered to and is only valid for 10 seconds.
The operating system pid
of the associated renderer process.
Get the system printer list.
The Chromium internal pid
of the associated renderer. Can be compared to the frameProcessId
passed by frame specific navigation events (e.g. did-frame-navigate
)
the type of the webContent. Can be backgroundPage
, window
, browserView
, remote
, webview
or offscreen
.
The user agent for this web page.
Returns the WebRTC IP Handling Policy.
By default this value is { min: 0, max: 0 }
, which would apply no restriction on the udp port range.
the current zoom factor.
the current zoom level.
Navigates to the specified offset from the "current entry".
Inserts text
to the focused element.
Starts inspecting element at position (x
, y
).
Opens the developer tools for the service worker context.
Opens the developer tools for the shared worker context.
Inspects the shared worker based on its ID.
Schedules a full repaint of the window this web contents is in.
Whether this page has been muted.
Whether this page is being captured. It returns true when the capturer count is large then 0.
Whether audio is currently playing.
Whether the web page is destroyed.
Whether the devtools view is focused .
Whether the devtools is opened.
Whether the main frame (and not just iframes or frames within it) is still loading.
Indicates whether offscreen rendering is enabled.
If offscreen rendering is enabled returns whether it is currently painting.
Whether the web page is waiting for a first-response from the main resource of the page.
the promise will resolve when the page has finished loading (see did-finish-load
), and rejects if the page fails to load (see did-fail-load
). A noop rejection handler is already attached, which avoids unhandled rejection errors.
Emitted when media becomes audible or inaudible.
Emitted before dispatching the keydown
and keyup
events in the page. Calling event.preventDefault
will prevent the page keydown
/keyup
events and the menu shortcuts.
Emitted when the WebContents
loses focus.
Emitted when failed to verify the certificate
for url
.
Emitted when the associated window logs a console message.
Emitted when the page calls window.moveTo
, window.resizeTo
or related APIs.
Emitted when there is a new context menu that needs to be handled.
Emitted when the cursor's type changes. The type
parameter can be pointer
, crosshair
, hand
, text
, wait
, help
, e-resize
, n-resize
, ne-resize
, nw-resize
, s-resize
, se-resize
, sw-resize
, w-resize
, ns-resize
, ew-resize
, nesw-resize
, nwse-resize
, col-resize
, row-resize
, m-panning
, m-panning-vertical
, m-panning-horizontal
, e-panning
, n-panning
, ne-panning
, nw-panning
, s-panning
, se-panning
, sw-panning
, w-panning
, move
, vertical-text
, cell
, context-menu
, alias
, progress
, nodrop
, copy
, none
, not-allowed
, zoom-in
, zoom-out
, grab
, grabbing
, custom
, null
, drag-drop-none
, drag-drop-move
, drag-drop-copy
, drag-drop-link
, ns-no-resize
, ew-no-resize
, nesw-no-resize
, nwse-no-resize
, or default
.
Emitted when webContents
is destroyed.
Emitted when DevTools is closed.
Emitted when DevTools is focused / opened.
Emitted when DevTools is opened.
Emitted when a link is clicked in DevTools or 'Open in new tab' is selected for a link in its context menu.
Emitted when the devtools window instructs the webContents to reload
Emitted when a <webview>
has been attached to this web contents.
Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
Emitted after successful creation of a window via window.open
in the renderer. Not emitted if the creation of the window is canceled from webContents.setWindowOpenHandler
.
This event is like did-finish-load
but emitted when the load failed. The full list of error codes and their meaning is available here.
This event is like did-fail-load
but emitted when the load was cancelled (e.g. window.stop()
was invoked).
Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning, and the onload
event was dispatched.
Emitted when a frame has done navigation.
Emitted when any frame navigation is done.
Emitted when a main frame navigation is done.
Emitted when an in-page navigation happened in any frame.
Emitted after a server side redirect occurs during navigation. For example a 302 redirect.
Corresponds to the points in time when the spinner of the tab started spinning.
Emitted when any frame (including main) starts navigating.
Corresponds to the points in time when the spinner of the tab stopped spinning.
Emitted when the document in the top-level frame is loaded.
Emitted when the window enters a full-screen state triggered by HTML API.
Emitted when the WebContents
gains focus.
Emitted when a result is available for webContents.findInPage
request.
Emitted when the mainFrame, an <iframe>
, or a nested <iframe>
is loaded within the page.
Emitted when an input event is sent to the WebContents. See InputEvent for details.
Emitted when the renderer process sends an asynchronous message via ipcRenderer.send()
.
Emitted when the renderer process sends a synchronous message via ipcRenderer.sendSync()
.
Emitted when the window leaves a full-screen state triggered by HTML API.
Emitted when webContents
wants to do basic auth.
Emitted when media is paused or done playing.
Emitted when media starts playing.
Emitted when page receives favicon urls.
Fired when page title is set during navigation. explicitSet
is false when title is synthesized from file url.
Emitted when a new frame is generated. Only the dirty area is passed in the buffer.
Emitted when a plugin process has crashed.
Emitted when the WebContents
preferred size has changed.
Emitted when the preload script preloadPath
throws an unhandled exception error
.
Emitted when the renderer process unexpectedly disappears. This is normally because it was crashed or killed.
Emitted when the unresponsive web page becomes responsive again.
Emitted when a bluetooth device needs to be selected when a call to navigator.bluetooth.requestDevice
is made. callback
should be called with the deviceId
of the device to be selected. Passing an empty string to callback
will cancel the request.
Emitted when a client certificate is requested.
Emitted when the web page becomes unresponsive.
Emitted when mouse moves over a link or the keyboard moves the focus to a link.
Emitted when a <webview>
's web contents is being attached to this web contents. Calling event.preventDefault()
will destroy the guest page.
Emitted when a user or the page wants to start navigation in any frame. It can happen when the window.location
object is changed or a user clicks a link in the page.
Emitted when a user or the page wants to start navigation on the main frame. It can happen when the window.location
object is changed or a user clicks a link in the page.
Emitted when a beforeunload
event handler is attempting to cancel a page unload.
Emitted when a server side redirect occurs during navigation. For example a 302 redirect.
Emitted when the user is requesting to change the zoom level using the mouse wheel.
Opens the devtools.
Executes the editing command pasteAndMatchStyle
in web page.
Send a message to the renderer process, optionally transferring ownership of zero or more MessagePortMain
objects.
When a custom pageSize
is passed, Chromium attempts to validate platform specific minimum values for width_microns
and height_microns
. Width and height must both be minimum 353 microns but may be higher on some operating systems.
Resolves with the generated PDF data.
Reloads current page and ignores cache.
Resolves if the removal was successful.
Removes the specified path from DevTools workspace.
Executes the editing command replaceMisspelling
in web page.
Scrolls to the bottom of the current webContents
.
Scrolls to the top of the current webContents
.
Send an asynchronous message to the renderer process via channel
, along with arguments. Arguments will be serialized with the Structured Clone Algorithm, just like postMessage
, so prototype chains will not be included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception.
Sends an input event
to the page. Note: The BrowserWindow
containing the contents needs to be focused for sendInputEvent()
to work.
Send an asynchronous message to a specific frame in a renderer process via channel
, along with arguments. Arguments will be serialized with the Structured Clone Algorithm, just like postMessage
, so prototype chains will not be included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception.
Mute the audio on the current web page.
Controls whether or not this WebContents will throttle animations and timers when the page becomes backgrounded. This also affects the Page Visibility API.
Changes the title of the DevTools window to title
. This will only be visible if DevTools is opened in undocked
or detach
mode.
Uses the devToolsWebContents
as the target WebContents
to show devtools.
If offscreen rendering is enabled sets the frame rate to the specified number. Only values between 1 and 240 are accepted.
Ignore application menu shortcuts while this web contents is focused.
Sets the image animation policy for this webContents. The policy only affects new images, existing images that are currently being animated are unaffected. This is a known limitation in Chromium, you can force image animation to be recalculated with img.src = img.src
which will result in no network traffic but will update the animation policy.
Overrides the user agent for this web page.
Sets the maximum and minimum pinch-to-zoom level.
Setting the WebRTC IP handling policy allows you to control which IPs are exposed via WebRTC. See BrowserLeaks for more details.
Setting the WebRTC UDP Port Range allows you to restrict the udp port range used by WebRTC. By default the port range is unrestricted. Note: To reset to an unrestricted port range this value should be set to { min: 0, max: 0 }
.
Called before creating a window a new window is requested by the renderer, e.g. by window.open()
, a link with target="_blank"
, shift+clicking on a link, or submitting a form with <form target="_blank">
. See window.open()
for more details and how to use this in conjunction with did-create-window
.
Changes the zoom factor to the specified factor. Zoom factor is zoom percent divided by 100, so 300% = 3.0.
Changes the zoom level to the specified level. The original size is 0 and each increment above or below represents zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. The formula for this is scale := 1.2 ^ level
.
Shows pop-up dictionary that searches the selected word on the page.
If offscreen rendering is enabled and not painting, start painting.
Stops any findInPage
request for the webContents
with the provided action
.
If offscreen rendering is enabled and painting, stop painting.
Indicates whether the snapshot has been created successfully.
Toggles the developer tools.