简体   繁体   中英

How to Intercept image load requests in WebView?

Is it possible to intercept image load requests in WebView before they are actually started and modify their URLs?

For example, I have

mWebView.loadUrl(myUrl);

In onLoadResources event I can see URLs, but I can't modify them?

The thing is I am working on application that loads html content from remote location. For some reason author excluded image path and in img src he just have file name. Existing iPhone application is using this html content and I assume the content is build the way that is the best for iPhone. So, I need somehow to figure how to alter these paths. For example, if I choose to download all images first, I would need to alter path and add file:///... in front of image.jpg name.

Thanks.

您可以使用onLoadResource,尽管不仅是图像,还可以加载任何资源,例如javascript和css

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