Hello test code,
Thanks for reaching out to Microsoft Q&A. Based on the information you provided, your application uses WebView2 to navigate to a URL via the CoreWebView2.NewWindowRequested event. However, on Windows 7, JavaScript interactions such as click actions do not work, and built-in events like SourceChanged and NavigationCompleted are not triggered, even though everything works fine on other operating systems.
The main reason is that WebView2 only supports Windows 7 up to runtime version 109. After January 2023, Microsoft stopped updating and supporting WebView2 for Windows 7. As a result, many modern APIs and features of WebView2—especially those related to window management, events, and advanced JavaScript interactions—will not function fully or may throw errors on Windows 7. The JavaScript error you encountered, Uncaught TypeError: Cannot read properties of undefined (reading 'postMessage'), is also related to missing or limited platform APIs in Windows 7.
The best solution is to upgrade your operating system to Windows 10 or Windows 11 to receive full support and features from WebView2. If you must use Windows 7, you should only use WebView2 for displaying static web content, avoid advanced events or complex JavaScript interactions, or consider using the older WebBrowser control (based on Internet Explorer), though this comes with its own limitations in web technology support.
References:
If you need more specific guidance on handling or refactoring your code, please provide more details about your use case.