【问题标题】:Remove pop out option in google drive/doc viewer in webview android在 webview android 中删除 google drive/doc 查看器中的弹出选项
【发布时间】:2015-08-31 12:57:40
【问题描述】:

在 webview android 中删除 google drive/doc 查看器中的弹出选项

我需要在webview中查看pdf,用户无法保存irt所以隐藏所有选项

【问题讨论】:

    标签: android


    【解决方案1】:
    //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'; })()");
            }
        })
    

    【讨论】:

    • 通过准确解释它如何解决原始问题中的问题,可以改进这个答案。纯代码答案不是很有用,因为它给读者带来了很大的负担,试图理解哪个部分最重要。
    • @William Price 请运行上面的代码.....希望我的简短解释能消除你的疑惑
    猜你喜欢
    • 1970-01-01
    • 2019-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多