Compartir a través de


CoreWebView2.PostWebMessageAsJsonWithAdditionalObjects Method

Definition

Same as PostWebMessageAsJson(String), but also has support for posting DOM objects to page content.

public void PostWebMessageAsJsonWithAdditionalObjects (string webMessageAsJson, System.Collections.Generic.List<object> additionalObjects);
member this.PostWebMessageAsJsonWithAdditionalObjects : string * System.Collections.Generic.List<obj> -> unit
Public Sub PostWebMessageAsJsonWithAdditionalObjects (webMessageAsJson As String, additionalObjects As List(Of Object))

Parameters

webMessageAsJson
String

The web message to be posted to the top level document in this WebView.

additionalObjects
List<Object>

Additional DOM objects posted to the content. This property is retrieved in web content via the DOM MessageEvent additionalObjects property as an array-like list of DOM objects. Currently these type of objects can be the posted: | .NET / WinRT | DOM type | |-------------------|-------------| | CoreWebView2FileSystemHandle | FileSystemHandle | | null | null | The objects are posted to web content, following the structured-clone semantics, meaning only objects that can be cloned can be posted. They will also behave as if they had been created by the web content they are posted to. For example, if a FileSystemFileHandle is posted to a web content it can only be re-transferred via postMessage to other web content with the same origin.

Remarks

The event args is an instance of MessageEvent. The IsWebMessageEnabled setting must be true or the message will not be sent. The event arg's data property of the event arg is the webMessageAsJson string parameter parsed as a JSON string into a JavaScript object. The event arg's source property of the event arg is a reference to the window.chrome.webview object. For information about sending messages from the HTML document in the WebView to the host, navigate to WebMessageReceived. The message is sent asynchronously. If a navigation occurs before the message is posted to the page, the message is not be sent.

Applies to

See also