Skip to content
Advertisement

UWP webView equivalent of addJavascriptInterface() from Android

I would like to now if there are some equivalent of addJavascriptInterface() from Android in UWP. From what I have read, first the script must be invoke through the method InvokeScript and in the JavaScript function window.external.notify() must be called. But I don´t want to invoke the javascript function, I just want to “wait” until the javaScriptFunction is called,. It would be like a listener of Javascript functions. Is this possible?

Advertisement

Answer

Finally I found what I wanted, this is the solution, use the WebView.AddWebAllowedObject method.

See also, “Accessing the Windows Runtime in WebView | WebView Class (Windows.UI.Xaml.Controls) – Windows UWP applications | Microsoft Docs

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement