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
unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT
unsafe fn get_source(&self, source: *mut LPWSTR) -> HRESULT
The URI of the document that sent this web message.
unsafe fn get_web_message_as_json(
&self,
web_message_as_json: *mut LPWSTR
) -> HRESULT
unsafe fn get_web_message_as_json(
&self,
web_message_as_json: *mut LPWSTR
) -> HRESULT
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\""
unsafe fn try_get_web_message_as_string(
&self,
web_message_as_string: *mut LPWSTR
) -> HRESULT
unsafe fn try_get_web_message_as_string(
&self,
web_message_as_string: *mut LPWSTR
) -> HRESULT
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
Check whether a given IID is in the inheritance hierarchy of this interface