Open rozele opened 6 years ago
I've reached out to the Web Platform team in Windows for further guidance on if we have any options for more general hooks in WebView.
Confirmed with Web Platforms team scenario to load JavaScript prior to page loading is not currently supported in UWP.
After the initial investigation, I've found two options for communication from the WebView back to the native bridge,
AddWebAllowedObject
andwindow.external.notify
.There are limitations with both of these: 1) WebView.AddWebAllowedObject works only works when navigated from NavigateToString or when navigating to a
ms-appx-web:
URI, and I have to introduce an additional WinRT component library in order to use it. 2)window.external.notify
only works when the URIs are whitelisted in the appxmanifest or from NavigateToString /ms-appx-web:
URIs.Currently, the most flexible is likely the
ScriptNotify
event andwindow.external.notify
, with the caveat that the app needs to declare upfront what domains are supported (and it must use HTTPS).