Help Center

CWebView2.IsWebMessageEnabledproperty

Determines whether communication from the host to the top-level HTML document of the WebView is allowed.

WebViewpropertydocumented

Syntax

PROPERTY IsWebMessageEnabled () AS BOOLEAN
PROPERTY IsWebMessageEnabled (BYVAL enabled AS BOOLEAN) AS HRESULT

Description

Used when loading a new HTML document.

Remarks

If set to TRUE, communication from the host to the top-level HTML document of the WebView is allowed using PostWebMessageAsJson, PostWebMessageAsString, and message event of window.chrome.webview. For more information, see PostWebMessageAsJson. Communication from the top-level HTML document of the WebView to the host is allowed using the postMessage function of window.chrome.webview and AddWebMessageReceived method. For more information, see AddWebMessageReceived. If set to false, then communication is disallowed. PostWebMessageAsJson and PostWebMessageAsString fails with E_ACCESSDENIED and window.chrome.webview.postMessage fails by throwing an instance of an Error object. The default value is TRUE.

Reference

  • Defined in AfxNova/CWebView2.inc:1011
  • Documented in WebView/CWebWiew2 Class.md
  • Topic: CWebView2 Class