I have a JavaScript script that looks for the location of an element in page using jQuery in a loaded WebView.
For some reason this script works only sometimes and I suspect that it's related to the time it takes to load the script or maybe the page.
I'm trying to evaluate the script only on onPageFinished
of the WebViewClient
interface, So I don't think that the loading of the page has something to do with it, but maybe I'm wrong.
I am an Android developer and have a very limited understanding in JavaScript and jQuery but I know the script works because the same script is used in the iOS platform and returns good results always.
Chances are there is some timing problem with loading the script itself.
So the question is: Is there a way to load the script before its usage, or load it and make sure it loaded into the WebView.
tag put a script tag with this code inside: $(document).ready(function(){ });
– Juan Jun 06 '17 at 12:36