android 获取WebView的网页高度

	wv.getSettings().setJavaScriptEnabled(true);
		wv.addJavascriptInterface(new HeightGetter(), "jo");

		wv.setWebViewClient(new WebViewClient() {

			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				return false;
			}

			public void onPageFinished(WebView view, String url) {
				wv.loadUrl("javascript:window.jo.run(document.documentElement.scrollHeight+'');");
			}
		});

		wv.loadUrl("http://www.baidu.com");



	private class HeightGetter {
		@JavascriptInterface
		public void run(final String height) {
			runOnUiThread(new Runnable() {
				public void run() {
					Toast.makeText(getApplicationContext(), height, 0).show();
				}
			});
		}
	}


你可能感兴趣的:(android)