Add an event handler for the WebMessageReceived event.
WebMessageReceived runs when the
ICoreWebView2Settings::IsWebMessageEnabled setting is set and the
frame document runs window.chrome.webview.postMessage.
The postMessage function is void postMessage(object)
where object is any object supported by JSON conversion.
When the frame calls postMessage, the object parameter is converted to a
JSON string and is posted asynchronously to the host process. This will
result in the handlers Invoke method being called with the JSON string
as its parameter.
Add an event handler for the WebMessageReceived event. WebMessageReceived runs when the ICoreWebView2Settings::IsWebMessageEnabled setting is set and the frame document runs window.chrome.webview.postMessage. The postMessage function is void postMessage(object) where object is any object supported by JSON conversion.
\snippet assets\ScenarioWebMessage.html chromeWebView
When the frame calls postMessage, the object parameter is converted to a JSON string and is posted asynchronously to the host process. This will result in the handlers Invoke method being called with the JSON string as its parameter.
\snippet ScenarioWebMessage.cpp WebMessageReceivedIFrame