简体   繁体   English

UWP webView与Android的addJavascriptInterface()等效

[英]UWP webView equivalent of addJavascriptInterface() from Android

I would like to now if there are some equivalent of addJavascriptInterface() from Android in UWP . 我现在想知道UWP是否有来自AndroidaddJavascriptInterface()等效项。 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. 根据我的阅读,首先必须通过InvokeScript方法调用脚本,并且必须在JavaScript函数window.external.notify()调用脚本。 But I don´t want to invoke the javascript function, I just want to "wait" until the javaScriptFunction is called,. 但是我不想调用javascript函数,我只是想“等待”直到调用javaScriptFunction。 It would be like a listener of Javascript functions. 它就像是Javascript函数的侦听器。 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. 当JavaScript函数window.external.notify() )发生时,会发生ScriptNotify事件( https://msdn.microsoft.com/zh-cn/library/windows/apps/windows.ui.xaml.controls.webview.scriptnotify.aspx )。 window.external.notify()在网页上被调用。 So you should add window.external.notify() calls to the JavaScript-functions you want to listen. 因此,您应该将window.external.notify()调用添加到要监听的JavaScript函数。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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