CoreWebView2Frame Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
CoreWebView2Frame provides direct access to the iframes information and handling. You can get a CoreWebView2Frame by handling the FrameCreated event.
public class CoreWebView2Frame
type CoreWebView2Frame = class
Public Class CoreWebView2Frame
- Inheritance
-
CoreWebView2Frame
Properties
| Name | Description |
|---|---|
| FrameId |
The unique identifier of the current frame. It's the same kind of ID as with the FrameId and FrameId. |
| Name |
The value of iframe's |
| UseOverrideTimerWakeInterval |
Indicates whether timer wake interval should be overridden for the frame. |
Methods
| Name | Description |
|---|---|
| AddHostObjectToScript(String, Object, IEnumerable<String>) |
Adds the provided host object to script running in the iframe with the specified name for the list of the specified origins. The host object will be accessible for this iframe only if the iframe's origin during access matches one of the origins which are passed. The provided origins will be normalized before comparing to the origin of the document. So the scheme name is made lower case, the host will be punycode decoded as appropriate, default port values will be removed, and so on. This means the origin's host may be punycode encoded or not and will match regardless. If list contains malformed origin the call will fail. The method can be called multiple times in a row without calling RemoveHostObjectFromScript for the same object name. It will replace the previous object with the new object and new list of origins. List of origins will be treated as following:
|
| ExecuteScriptAsync(String) |
Runs JavaScript code from the |
| IsDestroyed() |
Check whether a frame is destroyed. Returns a nonzero value if the frame is destroyed, including during the Destroyed event, and zero otherwise. |
| PostSharedBufferToScript(CoreWebView2SharedBuffer, CoreWebView2SharedBufferAccess, String) |
Share a shared buffer object with script of the iframe in the WebView. |
| PostWebMessageAsJson(String) |
Posts the specified |
| PostWebMessageAsString(String) |
Posts a message that is a simple string rather than a JSON string representation of a JavaScript object. |
| RemoveHostObjectFromScript(String) |
Remove the host object specified by the name so that it is no longer accessible from JavaScript code in the iframe. |
Events
| Name | Description |
|---|---|
| ContentLoading |
ContentLoading is raised before any content is loaded, including scripts added with AddScriptToExecuteOnDocumentCreatedAsync(String). ContentLoading is not raised if a same page navigation occurs. |
| DedicatedWorkerCreated |
Subscribe to this event that gets raised when a new dedicated worker is created from an iframe. A Dedicated Worker is a type of web worker that allows you to run Javascript code in the background without blocking the main thread, making them useful for tasks like heavy computations, data processing, and parallel execution. It is "dedicated" because it is linked to a single parent document and cannot be shared with other scripts. This event is raised when a web application creates a dedicated worker using the
|
| Destroyed |
Destroyed event is raised when the iframe corresponding to this CoreWebView2Frame object is removed or the document containing that iframe is destroyed. |
| DOMContentLoaded |
DOMContentLoaded is raised when the initial HTML document has been parsed. |
| FrameCreated |
FrameCreated is raised when a new direct descendant iframe is created. Handle this event to get access to CoreWebView2Frame objects. |
| LaunchingExternalUriScheme |
LaunchingExternalUriScheme is raised when content in this CoreWebView2Frame, or in one of its descendant iframes, attempts to launch a URI registered with the OS as an external scheme handler. This is the frame-level counterpart of the LaunchingExternalUriScheme event, allowing host apps to attribute external URI scheme launches to a specific iframe even when multiple frames share the same origin.
When the launch originates from a nested iframe, the event bubbles outward through the tracked CoreWebView2Frame ancestors, starting with the closest (innermost) tracked frame and proceeding outward toward the top-level frame. For an iframe-initiated launch, the CoreWebView2Frame event handlers are invoked before the LaunchingExternalUriScheme event handlers. If the Handled property is set to |
| NameChanged |
NameChanged is raised when the iframe changes its |
| NavigationCompleted |
NavigationCompleted is raised when the current frame has completely loaded ( |
| NavigationStarting |
NavigationStarting is raised when the current frame is requesting permission to navigate to a different URI. |
| PermissionRequested |
PermissionRequested is raised when content in an iframe or any of its descendant iframes requests permission to access some privileged resources. |
| ScreenCaptureStarting |
ScreenCaptureStarting event is raised when the Screen Capture API is requested by the user using getDisplayMedia(). |
| WebMessageReceived |
WebMessageReceived is raised when the IsWebMessageEnabled setting is set and the iframe runs |