1
votes

I want to load a html code into a webview. But the html code has several other external resources. for example in the html code I have :

<script type="text/javascript" src="//cdn3.example.com/example.js"></script>

but it seems that 'example.js' is not executed when rendering the webview.

Is it possible to achieve that ? Thank you

1
thank you, but I already have tested this and it's not working - yous
Nobody ? I'm on this problem for 4 days now ... - yous
Did you ever find a solution? - Mike6679

1 Answers

0
votes

I have similar issue, webview loaded from file:// and won't load external resources... cors set to * on the server side too.

So digging into it further, seems my problem was I used custom ssl certs on server side and android couldn't verify the server authenticity, and so requests were being cancelled. (adding intermediate certs to app would help)

alternately You can override webclient's shouldInterceptRequest and fetch the external scripts yourself, returning the request from which webview will draw data (make sure you don't fetch during the shouldInterceptRequest call or it will be slooooooow sequentially fetching resources; instead, return a request's subclass and start fetching data async, so by time call to getData comes you already have what you need... search so for async shouldInterceptRequest for help with that).