以下代码在页面上有下载选项。我想删除此选项,只允许访问者读取不下载的权限。
WebView mWebView = (WebView) findViewById( R.id.WebView01);
String pdfurl = ""; // Url of pdf or doc file.
String weblink="http://docs.google.com/gview?embedded=true&url="+pdfurl;
mWebView.loadUrl(weblink);
答案 0 :(得分:2)
使用http连接解析html使用jsoup ....捕获下载链接所在的标记并禁用它...它需要秒解析但有效地工作...
答案 1 :(得分:0)
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
webview.loadUrl("javascript:(function() { " +
"document.getElementsByClassName('ndfHFb-c4YZDc-GSQQnc-LgbsSe ndfHFb-c4YZDc-to915-LgbsSe VIpgJd-TzA9Ye-eEGnhe ndfHFb-c4YZDc-LgbsSe')[0].style.display='none'; })()");
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
})