简体   繁体   中英

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?

There is ScriptNotify event ( https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.webview.scriptnotify.aspx ) which occures when JavaScript function window.external.notify() is invoked on the web-page. So you should add window.external.notify() calls to the JavaScript-functions you want to listen.

终于我找到了我想要的, 这就是解决方案

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM