Partilhar via


CoreWebView2Frame Class

Definition

CoreWebView2Frame provides direct access to the iframes information and handling.

public class CoreWebView2Frame
type CoreWebView2Frame = class
Public Class CoreWebView2Frame
Inheritance
CoreWebView2Frame

Properties

FrameId

The unique identifier of the current frame. It's the same kind of ID as with the FrameId and FrameId.

Name

The name of the iframe from the iframe html tag declaring it.

UseOverrideTimerWakeInterval

Methods

AddHostObjectToScript(String, Object, IEnumerable<String>)

Adds the provided host object to script running in the WebViewFrame 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:

  1. empty list - call will succeed and object will be added for the iframe but it will not be exposed to any origin;
  2. list with origins - during access to host object from iframe the origin will be checked that it belongs to this list;
  3. list with "*" element - host object will be available for iframe for all origins. We suggest not to use this feature without understanding security implications of giving access to host object from from iframes with unknown origins.
  4. list with "file://" element - host object will be available for iframes loaded via file protocol.
ExecuteScriptAsync(String)

Runs JavaScript code from the javaScript parameter in the current frame.

IsDestroyed()

Check whether a frame is destroyed. Returns true during the Destroyed event.

PostSharedBufferToScript(CoreWebView2SharedBuffer, CoreWebView2SharedBufferAccess, String)

Share a shared buffer object with script of the iframe in the WebView.

PostWebMessageAsJson(String)

Posts the specified webMessageAsJson to the current frame.

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

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.

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.

NameChanged

NameChanged is raised when the iframe changes its window.name property.

NavigationCompleted

NavigationCompleted is raised when the current frame has completely loaded (body.onload has been raised) or loading stopped with error.

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 window.chrome.webview.postMessage.

Applies to