0

From where exactly should we try to add a listener to body (or any other tag) tag using JS in Android webview.

Because in onPageStarted() the element might not have been loaded and in onPageFinished() the element might have already completed loading.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Midhun Kumar
  • 549
  • 5
  • 23

1 Answers1

0

You know that onPageFinished() and onPageStarted() are android methodes and not JS methodes. If you want to use JS that only is excuted when your page is load you need to do something like this:

var init = function () {
    DoSomeFunction();
};

$(document).ready(init());
Steven
  • 1,404
  • 2
  • 16
  • 39
  • so jquerys ready gets executed only when all the resources are loaded? Does it include complete loading of a script added using the cdn url (mathjax)? – Midhun Kumar Jul 06 '17 at 09:35
  • Are you using a cdn in webview your not loading it local mathJax? the init will only be excuted when the webpage is completely loaded. – Steven Jul 06 '17 at 09:37