开发者

Is there any way to intercept javascript triggered URL in webview?

开发者 https://www.devze.com 2023-01-13 18:15 出处:网络
Is there any way to intercept javascript triggered URL in a WebView just like normal hrefs using shouldOverride开发者_运维百科UrlLoading()?onLoadResource() is called when any resource is being called,

Is there any way to intercept javascript triggered URL in a WebView just like normal hrefs using shouldOverride开发者_运维百科UrlLoading()?


onLoadResource() is called when any resource is being called, including JavaScript. The purpose is a bit different though than shouldOverrideUrlLoading().

webControls.setWebViewClient(new WebViewClient() { 
    //Notify the host application that the WebView will load 
    //the resource specified by the given url.
    @Override  
    public void onLoadResource (WebView view, String url) {
        super.onLoadResource(view, url);
        Log.v(TAG, "onLoadResource("+url+");");
    }

    //Give the host application a chance to take over the 
    //control when a new url is about to be loaded in the 
    //current WebView. 
    @Override  
    public void shouldOverrideUrlLoading(WebView view, String url) {
        super.shouldOverrideUrlLoading(view, url);
        Log.v(TAG, "shouldOverrideUrlLoading("+url+");");
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消