webContents Type
⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ❌ | Exported ✔
Render and control web pages.Process: MainwebContents is an EventEmitter. It is responsible for rendering and controlling a web page and is a property of the BrowserWindow object. An example of accessing the webContents object:### Navigation EventsSeveral events can be used to monitor navigations as they occur within a webContents.### Document NavigationsWhen a webContents navigates to another page (as opposed to an in-page navigation), the following events will be fired.* did-start-navigation* will-frame-navigate* will-navigate (only fired when main frame navigates)* will-redirect (only fired when a redirect happens during navigation)* did-redirect-navigation (only fired when a redirect happens during navigation)* did-frame-navigate* did-navigate (only fired when main frame navigates)Subsequent events will not fire if event.preventDefault() is called on any of the cancellable events.### In-page NavigationIn-page navigations don't cause the page to reload, but instead navigate to a location within the current page. These events are not cancellable. For an in-page navigations, the following events will fire in this order:* did-start-navigation* did-navigate-in-page### Frame NavigationThe will-navigate and did-navigate events only fire when the mainFrame navigates. If you want to also observe navigations in
Static members
| Static member |
Description
|
Full Usage:
webContents.fromDevToolsTargetId targetId
Parameters:
string
Returns: Option<WebContents>
Modifiers: inline |
A WebContents instance with the given TargetID, or undefined if there is no WebContents associated with the given TargetID.When communicating with the Chrome DevTools Protocol, it can be useful to lookup a WebContents instance based on its assigned TargetID.
|
Full Usage:
webContents.fromFrame frame
Parameters:
WebFrameMain
Returns: Option<WebContents>
Modifiers: inline |
A WebContents instance with the given WebFrameMain, or undefined if there is no WebContents associated with the given WebFrameMain.
|
Full Usage:
webContents.fromId id
Parameters:
int
Returns: Option<WebContents>
Modifiers: inline |
A WebContents instance with the given ID, or undefined if there is no WebContents associated with the given ID.
|
|
An array of all WebContents instances. This will contain web contents for all windows, webviews, opened devtools, and devtools extension background pages.
|
|
The web contents that is focused in this application, otherwise returns null.
|
fable-electron-docs-api