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);
网友评论