ICoreWebView2Frame2.PostWebMessageAsJson

Posts the specified webMessage to the frame. The frame receives the message by subscribing to the message event of the window.chrome.webview of the frame document.

window.chrome.webview.addEventListener('message', handler)
window.chrome.webview.removeEventListener('message', handler)

The event args is an instances of MessageEvent. The ICoreWebView2Settings::IsWebMessageEnabled setting must be TRUE or the message will not be sent. The data property of the event args is the webMessage string parameter parsed as a JSON string into a JavaScript object. The source property of the event args 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 add_WebMessageReceived. The message is delivered asynchronously. If a navigation occurs before the message is posted to the page, the message is discarded.

interface ICoreWebView2Frame2
HRESULT
PostWebMessageAsJson
(
in LPCWSTR webMessageAsJson
)

Meta