Help Center

CWebView2.ExecuteScriptmethod

Run JavaScript code from the javascript parameter in the current top-level document rendered in the WebView.

WebViewmethoddocumented

Syntax

FUNCTION ExecuteScript (BYVAL javaScript AS LPCWSTR, BYVAL handler AS Afx_ICoreWebView2ExecuteScriptCompletedHandler PTR) AS HRESULT

Parameters

NameDescription
javaScript[in] The Java script.
handler[in] Pointer to an implemented Afx_ICoreWebView2ExecuteScriptCompletedHandler callback interface.

Description

Run JavaScript code from the javascript parameter in the current top-level document rendered in the WebView.

The result of evaluating the provided JavaScript is used in this parameter. The result value is a JSON encoded string. If the result is undefined, contains a reference cycle, or otherwise is not able to be encoded into JSON, then the result is considered to be null, which is encoded in JSON as the string "null".

Reference

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