[英]How can I pass javascript function to webview?
I have a unique situation.我有一个独特的情况。 I need to pass a javascript method to webview so that the web app I am launching in the webview is able to call that method to notify loading status.
我需要向 webview 传递一个 javascript 方法,以便我在 webview 中启动的 web 应用程序能够调用该方法来通知加载状态。 The loading status will be error, loading, done etc. The default loading status was not giving us an accurate idea so our spinner would disappear but the web app would not have completed loading.
加载状态将是错误、加载、完成等。默认加载状态并没有给我们一个准确的想法,所以我们的微调器会消失,但网络应用程序不会完成加载。 So we want the webapp to let Android know when its actually done loading.
所以我们希望 webapp 在它真正完成加载时让 Android 知道。 How can I achieve this?
我怎样才能做到这一点?
The method you are describing is basically webview script injection.您所描述的方法基本上是 webview 脚本注入。 Sometimes knowing the name of something makes all the difference.
有时,知道某物的名称会让一切变得不同。 There are many tutorials out there so I'll just link some here:
那里有很多教程,所以我只在这里链接一些:
Inject JS into Android's WebView 将 JS 注入 Android 的 WebView
Inject javascript file to my site with webview in android 在android中使用webview将javascript文件注入我的网站
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.