-
Notifications
You must be signed in to change notification settings - Fork 499
Description
Add a sample demonstrating best practice to communicate events between the host and javascript both ways.
An messaging abstraction would benefit the WebView2 spec. There is a supported 'WebMessageReceived' API but is only from Host originated events which await a JS response.
The WebView2_spec says: "WebMessageReceived – Occurs when the content contained in the WebView2 control passes a string to the application by using JavaScipt."
a sample showing how to send messages from JavaScript to the Native application hosting the WebView would be very useful.
"Win32 WebViewControl did not support ObjectForScripting or AddWebAllowedObject", @rjmurillo made a fine example of a necessary workaround to create a Javascript to Natvie notification 'JavaScriptBridge'.
It's basis was :
window.external.notify(event.data);
The browser MDN web docs on Window.external say it is deprecated. What would be the Chrome equivalent?
An iOS Safari webView compatible example:
https://github.com/lovesunstar/WKBridge/blob/fb30c123e68b4dcd4c4a2a8087d7383dbac0afe9/Example/WKBridge/test.html