2020-08-24

2020-08-24  本文已影响0人  Amy木婉清

Webview续集

1.WebChromeClient中onReceivedTitle是获取网页标题.

    class MyWebChromeClient extends WebChromeClient{
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
            setTitle(title);
        }
    }

运行结果的标题为百度一下,而不是最开始的项目名称,因此该方法可以获取网页标题名称.
2.js代码弹出对话框的两种写法

(1) mWvMain.loadUrl("javascript:alert('hello')");
(2) mWvMain.evaluateJavascript("javascript:alert('hello')",null);
上一篇下一篇

猜你喜欢

热点阅读