简体   繁体   中英

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. 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. How can I achieve this?

The method you are describing is basically webview script injection. 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

Inject javascript file to my site with webview in android

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