My C++ code has these steps, trying to get JavaScript-generated HTML codes.
- Call
ICoreWebView2Settings::put_IsScriptEnabledto turn on JavaScript feature - Call
ICoreWebView2::NavigateToStringto set an in-memory webpage. - When
NavigationCompletedhappens, we harvest the HTML codes of the entire web page.
Unfortunately, there is apparently a race condition. Sometimes, JavaScript codes in <body> are ignored, and only the JavaScript codes in <head> have effect. Sometimes, we get <html><head></head><body></body></html>.
When using ICoreWebView2::Navigate to open a remote web page, I didn't see this problem. It seems a bug in ICoreWebView2::NavigateToString. Therefore, replacing ICoreWebView2::NavigateToString with ICoreWebView2::Navigate seems to be a better choice, but I don't know how to use ICoreWebView2::Navigate to open an in-memory HTML document. What scheme shall I use? file:// or memory://, etc.? Any suggestion? Thanks.
