4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HTML上の特定の要素を非表示にする

Last updated at Posted at 2016-04-20

この記事はhttp://buildbox.net/?p=782 からの転載です。

AndroidでWebViewを表示するとき、特定の項目だけ非表示にしたい場合の方法を探して見つけたので、メモ。

WebViewClient webViewClient = new WebViewClient() {
    @Override
    public void onPageFinished(WebView view, String url) {
        // 不要な項目を消す
                view.loadUrl("javascript:document.getElementById('id').setAttribute(\"style\",\"display:none;\");");
        }
}

WebViewClient#onPageFinishedメソッドのタイミングで、loadUrlメソッドを使って、HTML要素を非表示とするJavaScriptを実行してやればOK。

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?