Try use the code provided in this answer instead.
InvokeScript("eval",args) on webview2

i will try execute eval javascript on webview2 wpf project , on webroser worke fine InvokeScript("eval",args) but in webview2 not woke plz can you help me .
2 answers
Sort by: Most helpful
-
-
DaisyTian-1203 11,511 Reputation points
2021-03-04T09:27:57.27+00:00 The old one which is named WebView has
InvokeScript
method, but there is no method in WebView2 Class Method likeInvokeScript
in WebBrowser Class Method and WebView Class Method. You can use WebView2.ExecuteScriptAsync(String) Method to execute JavaScript code from the javaScript parameter in the current top level document rendered in the WebView. To include the args for the eval, you can use it as below:
By the way, you can create your custom InvokeScript method referring to cheong00's reply.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.