Search code examples
javascriptandroidwebviewframes

Android WebView: Is there an on onPageFinished when a link targets a frame?


I'm trying to execute some javascript after a frame is completed loading in a webview.

here is the link:

<a target="viewer" href="./Inbox/?Cmd=contents&Page=1">

here is the frame:

<frame scrolling="auto" src="Inbox/?Cmd=contents" title="Contents" name="viewer">

I can use the following but this only works if the entire page is the target, not just a frame:

webview.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageFinished(WebView view, String url) {
    }
}

This is code that is retro and cannot be altered by me, only JavaScript added after the fact. Any help would be great!


Solution

  • I was able to get the result by overloading this method in the WebViewCLient @Override public void onLoadResource(WebView view,String urlNewString) { System.err.println("onLoadResource " + urlNewString); } This would return ALL URL resources loaded but ALSO the page itself. I was able to filter out information in the URL address to execute specific code for each link that opened for each frame