Header menu logo fable-electron-docs-api

WebContents Type

⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ❌ | Exported ❌

Instance members

Instance member Description

this.addWorkSpace path

Full Usage: this.addWorkSpace path

Parameters:
    path : string

Modifiers: inline

Adds the specified path to DevTools workspace. Must be used after DevTools creation:

path : string

this.adjustSelection (?start, ?end)

Full Usage: this.adjustSelection (?start, ?end)

Parameters:
    ?start : float
    ?end : float

Modifiers: inline

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.Example:For a call of win.webContents.adjustSelection({ start: 1, end: 5 })Before:After:

?start : float
?end : float

this.audioMuted

Full Usage: this.audioMuted

A boolean property that determines whether this page is muted.

this.backgroundThrottling

Full Usage: this.backgroundThrottling

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.

this.beginFrameSubscription (?onlyDirty, ?callback)

Full Usage: this.beginFrameSubscription (?onlyDirty, ?callback)

Parameters:
Modifiers: inline

Begin subscribing for presentation events and captured frames, the callback will be called with callback(image, dirtyRect) when there is a presentation event.The image is an instance of NativeImage that stores the captured frame.The dirtyRect is an object with x, y, width, height properties that describes which part of the page was repainted. If onlyDirty is set to true, image will only contain the repainted area. onlyDirty defaults to false.

?onlyDirty : bool
?callback : NativeImage * Rectangle -> unit

this.capturePage (?rect, ?stayHidden, ?stayAwake)

Full Usage: this.capturePage (?rect, ?stayHidden, ?stayAwake)

Parameters:
    ?rect : Rectangle
    ?stayHidden : bool
    ?stayAwake : bool

Returns: Promise<NativeImage>
Modifiers: inline

Resolves with a NativeImageCaptures a snapshot of the page within rect. Omitting rect will capture the whole visible page. The page is considered visible when its browser window is hidden and the capturer count is non-zero. If you would like the page to stay hidden, you should ensure that stayHidden is set to true.

?rect : Rectangle
?stayHidden : bool
?stayAwake : bool
Returns: Promise<NativeImage>

this.centerSelection ()

Full Usage: this.centerSelection ()

Modifiers: inline

Centers the current text selection in web page.

this.close waitForBeforeUnload

Full Usage: this.close waitForBeforeUnload

Parameters:
    waitForBeforeUnload : bool

Modifiers: inline

Closes the page, as if the web content had called window.close().If the page is successfully closed (i.e. the unload is not prevented by the page, or waitForBeforeUnload is false or unspecified), the WebContents will be destroyed and no longer usable. The destroyed event will be emitted.

waitForBeforeUnload : bool

this.closeDevTools ()

Full Usage: this.closeDevTools ()

Modifiers: inline

Closes the devtools.

this.copy ()

Full Usage: this.copy ()

Modifiers: inline

Executes the editing command copy in web page.

this.copyImageAt (x, y)

Full Usage: this.copyImageAt (x, y)

Parameters:
    x : int
    y : int

Modifiers: inline

Copy the image at the given position to the clipboard.

x : int
y : int

this.cut ()

Full Usage: this.cut ()

Modifiers: inline

Executes the editing command cut in web page.

this.debugger

Full Usage: this.debugger

Returns: Debugger

A Debugger instance for this webContents.

Returns: Debugger

this.delete ()

Full Usage: this.delete ()

Modifiers: inline

Executes the editing command delete in web page.

this.devToolsWebContents

Full Usage: this.devToolsWebContents

Returns: Option<WebContents>

A WebContents | null property that represents the of DevTools WebContents associated with a given WebContents.> [!NOTE] Users should never store this object because it may become null when the DevTools has been closed.

Returns: Option<WebContents>

this.disableDeviceEmulation ()

Full Usage: this.disableDeviceEmulation ()

Modifiers: inline

Disable device emulation enabled by webContents.enableDeviceEmulation.

this.downloadURL (url, ?headers)

Full Usage: this.downloadURL (url, ?headers)

Parameters:
    url : string
    ?headers : Record<string, string>

Modifiers: inline

Initiates a download of the resource at url without navigating. The will-download event of session will be triggered.

url : string
?headers : Record<string, string>

this.enableDeviceEmulation (screenPosition, screenSize, viewPosition, deviceScaleFactor, viewSize, scale)

Full Usage: this.enableDeviceEmulation (screenPosition, screenSize, viewPosition, deviceScaleFactor, viewSize, scale)

Parameters:
Modifiers: inline

Enable device emulation with the given parameters.

screenPosition : ScreenPosition
screenSize : Size
viewPosition : Point
deviceScaleFactor : int
viewSize : Size
scale : float

this.endFrameSubscription ()

Full Usage: this.endFrameSubscription ()

Modifiers: inline

End subscribing for frame presentation events.

this.executeJavaScript (code, ?userGesture)

Full Usage: this.executeJavaScript (code, ?userGesture)

Parameters:
    code : string
    ?userGesture : bool

Returns: Promise<obj>
Modifiers: inline

A promise that resolves with the result of the executed code or is rejected if the result of the code is a rejected promise.Evaluates code in 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.Code execution will be suspended until web page stop loading.

code : string
?userGesture : bool
Returns: Promise<obj>

this.executeJavaScriptInIsolatedWorld (worldId, scripts, ?userGesture)

Full Usage: this.executeJavaScriptInIsolatedWorld (worldId, scripts, ?userGesture)

Parameters:
    worldId : int
    scripts : WebSource[]
    ?userGesture : bool

Returns: Promise<obj>
Modifiers: inline

A promise that resolves with the result of the executed code or is rejected if the result of the code is a rejected promise.Works like executeJavaScript but evaluates scripts in an isolated context.

worldId : int
scripts : WebSource[]
?userGesture : bool
Returns: Promise<obj>

this.findInPage (text, ?forward, ?findNext, ?matchCase)

Full Usage: this.findInPage (text, ?forward, ?findNext, ?matchCase)

Parameters:
    text : string
    ?forward : bool
    ?findNext : bool
    ?matchCase : bool

Returns: int
Modifiers: inline

The request id used for the request.Starts a request to find all matches for the text in the web page. The result of the request can be obtained by subscribing to found-in-page event.

text : string
?forward : bool
?findNext : bool
?matchCase : bool
Returns: int

this.focus ()

Full Usage: this.focus ()

Modifiers: inline

Focuses the web page.

this.focusedFrame

Full Usage: this.focusedFrame

Returns: Option<WebFrameMain>

A WebFrameMain | null property that represents the currently focused frame in this WebContents. Can be the top frame, an inner