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.
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.