Android WebView: удаление всплывающего окна в google drive/doc viewer
Я загружаю pdf-документы в WebView, добавляя pdf-url к google doc api
http://docs.google.com/gview?embedded=true&url=myurl
Pdf загружается просто отлично, но веб-страница отображает две опции - Zoom-in
и Pop-Out
. Есть ли способ отключить/скрыть опцию pop-out, отправив некоторый параметр? Любая помощь будет оценена. Спасибо заранее!
![enter image description here]()
Ответы
Ответ 1
Вы можете добавить этот обратный вызов, и в результате кнопка "pop-out" будет удалена.
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mWebView.loadUrl("javascript:(function() { " +
"document.querySelector('[role=\"toolbar\"]').remove();})()");
}
Примечание. Если вы хотите показать эту кнопку вообще, сделайте свой веб-вид видимым после применения последнего кода javascript.
Ответ 2
//initialze WebView
webview = (WebView) findViewById(R.id.fullscree_webview);
//set the javascript enable to your webview
webview.getSettings().setJavaScriptEnabled(true);
//set the WebViewClient
webview.setWebViewClient(new WebViewClient() {
//once the page is loaded get the html element by class or id and through javascript hide it.
@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'; })()");
}
})
Ответ 3
Вот код, который можно отключить:
<div style="width: 640px; height: 480px; position: relative;">
<iframe src="https://drive.google.com/file/d/0ByzS..." width="640" height="480"
frameborder="0" scrolling="no" seamless="" allowfullscreen="allowfullscreen"></iframe>
<div style="width: 80px; height: 80px; position: absolute; opacity: 0; right: 0px; top: 0px;"></div>
</div>