Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Windows.Forms.WebBrowser.Document WebView2 equivalent #121

Closed
jwilburn opened this issue Jan 27, 2022 · 3 comments
Closed

System.Windows.Forms.WebBrowser.Document WebView2 equivalent #121

jwilburn opened this issue Jan 27, 2022 · 3 comments

Comments

@jwilburn
Copy link

trying to update some legacy code with WebView2 and can't find an equivalent property for System.Windows.Forms.WebBrowser.Document, https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.webbrowser.document?view=windowsdesktop-6.0

is there a property that supports this functionality off the base object and or CoreWebView2?

@champnic
Copy link
Member

champnic commented Jan 28, 2022

Hey @jwilburn - WebView2 doesn't give direct access to DOM elements. Instead you should use ExecuteScriptAsync to run script that manipulates the DOM as you need it. More info on native <-> web interop is here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/how-to/communicate-btwn-web-native

We are tracking adding support for HTML/DOM access here:
MicrosoftEdge/WebView2Feedback#77

Thanks!

@jwilburn
Copy link
Author

Hey @champnic, I don't need to manipulate the DOM, I just access to a property that would return the entire HTML document. Is that available?

@champnic
Copy link
Member

You should be able to do something like var html = ExecuteScriptAsync("document.body.innerHTML;");.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants