Thanks in advance.
In my application, I am replacing the WebBrowser control with Microsoft's WebView2.
I wish to know the equivalent of the below members of WebBrowser control in WebView2.
Does anyone have an answer ? Thanks again.
1. WebBrowser.ObjectForScripting: You should be able to use the AddHostObjectToScript API
WebView2.CoreWebView2.AddHostObjectToScript(...)
2. WebBrowser.Document: WebView2 doesn't give a way to interact directly with the DOM like this. Depending on what you're trying to accomplish, you can get the HTML of the page to inspect, or use script injection instead to operate on the Document Object Model.
For getting the HTML, you can checkout VB.Net Webview2 How can I get html source code? or How to obtain html contents of the page.
For script injection you can checkout the answer to this question which references using ExecuteScriptAsync or web messaging.
You could also try this 3rd-party project which aims to give control over the DOM similar to what WebBrowser.Document does: https://github.com/ukandrewc/Webview2.Winforms.DOM