Compartir a través de


CoreWebView2Frame.WebMessageReceived Event

Definition

WebMessageReceived is raised when the IsWebMessageEnabled setting is set and the iframe runs window.chrome.webview.postMessage.

public event EventHandler<Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs> WebMessageReceived;
member this.WebMessageReceived : EventHandler<Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs> 
Public Custom Event WebMessageReceived As EventHandler(Of CoreWebView2WebMessageReceivedEventArgs) 

Event Type

Examples

void WebView_FrameCreatedWebMessages(object sender, CoreWebView2FrameCreatedEventArgs args)
{
    args.Frame.WebMessageReceived += (WebMessageReceivedSender, WebMessageReceivedArgs) =>
    {
        HandleWebMessage(WebMessageReceivedArgs);
    };
}

Remarks

The postMessage function is void postMessage(object) where object is any object supported by JSON conversion. When postMessage is called, the handler's Invoke method will be called with the object parameter postMessage converted to a JSON string.

Applies to