Header menu logo fable-electron-docs-api

WebContentsView Type

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

A View that displays a WebContents.Process: MainThis module cannot be used until the ready event of the app module is emitted.### Class: WebContentsView extends View> A View that displays a WebContents.Process: MainWebContentsView inherits from View.WebContentsView is an EventEmitter.> [!WARNING] Electron's built-in classes cannot be subclassed in user code. For more information, see the FAQ.

Constructors

Constructor Description

WebContentsView(?webPreferences, ?webContents)

Full Usage: WebContentsView(?webPreferences, ?webContents)

Parameters:
    ?webPreferences : WebPreferences - Settings of web page's features.
    ?webContents : WebContents - If present, the given WebContents will be adopted by the WebContentsView. A WebContents may only be presented in one WebContentsView at a time.

Returns: WebContentsView
?webPreferences : WebPreferences

Settings of web page's features.

?webContents : WebContents

If present, the given WebContents will be adopted by the WebContentsView. A WebContents may only be presented in one WebContentsView at a time.

Returns: WebContentsView

Instance members

Instance member Description

this.addChildView (view, ?index)

Full Usage: this.addChildView (view, ?index)

Parameters:
    view : View
    ?index : int

Modifiers: inline

If the same View is added to a parent which already contains it, it will be reordered such that it becomes the topmost view.

view : View
?index : int

this.children

Full Usage: this.children

Returns: View[]

A View[] property representing the child views of this view.

Returns: View[]

this.getBounds ()

Full Usage: this.getBounds ()

Returns: Rectangle
Modifiers: inline

The bounds of this View, relative to its parent.

Returns: Rectangle

this.getVisible ()

Full Usage: this.getVisible ()

Returns: bool
Modifiers: inline

Whether the view should be drawn. Note that this is different from whether the view is visible on screen—it may still be obscured or out of view.

Returns: bool

this.offBoundsChanged handler

Full Usage: this.offBoundsChanged handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the view's bounds have changed in response to being laid out. The new bounds can be retrieved with view.getBounds().

handler : unit -> unit

this.onBoundsChanged handler

Full Usage: this.onBoundsChanged handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the view's bounds have changed in response to being laid out. The new bounds can be retrieved with view.getBounds().

handler : unit -> unit

this.onceBoundsChanged handler

Full Usage: this.onceBoundsChanged handler

Parameters:
    handler : unit -> unit

Modifiers: inline

Emitted when the view's bounds have changed in response to being laid out. The new bounds can be retrieved with view.getBounds().

handler : unit -> unit

this.removeChildView view

Full Usage: this.removeChildView view

Parameters:
Modifiers: inline

If the view passed as a parameter is not a child of this view, this method is a no-op.

view : View

this.setBackgroundColor color

Full Usage: this.setBackgroundColor color

Parameters:
    color : string

Modifiers: inline

Examples of valid color values:* Hex * #fff (RGB) * #ffff (ARGB) * #ffffff (RRGGBB) *

ffffffff (AARRGGBB)* RGB * rgb(([\d]+),\s*([\d]+),\s*([\d]+)) * e.g. rgb(255, 255, 255)* RGBA * rgba(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+))

  • e.g. rgba(255, 255, 255, 1.0)* HSL * hsl((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%) * e.g. hsl(200, 20%, 50%)* HSLA
  • hsla((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)) * e.g. hsla(200, 20%, 50%, 0.5)* Color name * Options are listed in SkParseColor.cpp * Similar to CSS Color Module Level 3 keywords, but case-sensitive. * e.g. blueviolet or red> [!NOTE] Hex format with alpha takes AARRGGBB or ARGB, not RRGGBBAA or RGB.

color : string

this.setBorderRadius radius

Full Usage: this.setBorderRadius radius

Parameters:
    radius : int

Modifiers: inline

[!NOTE] The area cutout of the view's border still captures clicks.

radius : int

this.setBounds bounds

Full Usage: this.setBounds bounds

Parameters:
Modifiers: inline
bounds : Rectangle

this.setVisible visible

Full Usage: this.setVisible visible

Parameters:
    visible : bool

Modifiers: inline
visible : bool

this.webContents

Full Usage: this.webContents

Returns: WebContents

A WebContents property containing a reference to the displayed WebContents. Use this to interact with the WebContents, for instance to load a URL.

Returns: WebContents

Type something to start searching.