Android WebView solves the problem that the nested iframe of the webpage cannot get the title

question:

1. The web page that starts to load has no title, so what is obtained is the address, which is a long list.

2. The iframe is the loaded content, but all the methods of WebView do not respond to events. Many netizens said other methods, and they debugged it themselves, but they didn't work.

 

Write your own method, get it in a loop until it is not an address. Of course, the leftover bugs need to be re-developed in practical applications and according to your own business. Give an idea first:

 @Override
public void onPageFinished(WebView view, String url) {
           //            title.setText(view.getTitle());
setTtile(view);
            super.onPageFinished(view, url);
}

        private void setTtile(final WebView view) {
            if (view.getTitle().length() > 30) {
                title.setText("加载中");
                new Handler().postDelayed(new Runnable() {
                    public void run() {
                        setTtile(view);
}
                }, 1000);
} else {
                title.setText(view.getTitle());
}
        }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326248367&siteId=291194637