Trait webview2_sys::ICoreWebView2WebMessageReceivedEventArgs[][src]

pub trait ICoreWebView2WebMessageReceivedEventArgs: IUnknown {
    unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT;
unsafe fn get_web_message_as_json(
        &self,
        web_message_as_json: *mut LPWSTR
    ) -> HRESULT;
unsafe fn try_get_web_message_as_string(
        &self,
        web_message_as_string: *mut LPWSTR
    ) -> HRESULT; }
Expand description

Event args for the WebMessageReceived event.

Required methods

The URI of the document that sent this web message.

The message posted from the WebView content to the host converted to a JSON string. Run this operation to communicate using JavaScript objects.

For example, the following postMessage runs result in the following WebMessageAsJson values.

postMessage({'a': 'b'})      L"{\"a\": \"b\"}"
postMessage(1.2)             L"1.2"
postMessage('example')       L"\"example\""

If the message posted from the WebView content to the host is a string type, this method returns the value of that string. If the message posted is some other kind of JavaScript type this method fails with the following error.

E_INVALIDARG

Run this operation to communicate using simple strings.

For example, the following postMessage runs result in the following WebMessageAsString values.

postMessage({'a': 'b'})      E_INVALIDARG
postMessage(1.2)             E_INVALIDARG
postMessage('example')       L"example"

Trait Implementations

A COM compatible V-Table

The interface that this interface inherits from

The associated id for this interface

Check whether a given IID is in the inheritance hierarchy of this interface

Get the vtable for a particular COM interface

Implementations on Foreign Types

Implementors