Handle URL from onCreateWindow WebView

前端 未结 3 483
情深已故
情深已故 2021-01-04 18:35

Can I get URL from calling onCreateWindow on WebView?

@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boole         


        
3条回答
  •  再見小時候
    2021-01-04 19:08

    You can get clicked URL by using this code.

    @Override
    public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture,
            Message resultMsg) {
        Message href = view.getHandler().obtainMessage();
        view.requestFocusNodeHref(href);
    
        String url = href.getData().getString("url");
        handleUrl(url); // handle the url here
    
        return super.onCreateWindow(view, isDialog, isUserGesture, resultMsg);
    }
    

提交回复
热议问题