I am writing an application for android, it has its own local browser, it comes to the page, and id header should be removed from this page.
Line

view.loadUrl("javascript:document.getElementsById('header').style.display = 'none'; "); 

for some reason does not work, but if you do so

 mWebView.loadUrl("javascript:var x = document.getElementsByClassName('header'); document.write(x); "); 

then it will output [objectHTMLCollection ].
Moreover, if you do this

 "javascript:var x = document.getElementsByClassName('header'); x.style.display = 'none';" 

then nothing happens either.
Question: how can I still hide this element?

    1 answer 1

     "javascript:var x = document.getElementsByClassName('header'); x.style.display = 'none';" 

    it is necessary to alter something like this:

     "javascript:var x = document.getElementsByClassName('header'); for (i=0;i<x.length;i++) { x[i].style.display = 'none';}" 
    • no, also for some reason it does not work, [objectHTMLCollection] if it gives out like that, then it turns out an array? - Goshka Tarasov
    • Well, in general, yes, this is a set of nodes, which means there is a list of them. It is necessary to go through the list, see here: jsfiddle.net/52opq6k2 - binliz
    • one
      @binliz Thanks for the help, but it works this way mWebView.loadUrl ("javascript: (function () {document.getElementById ('header'). style.display = 'none';}) ()"); mWebView.loadUrl ("javascript: window.CallToAnAndroidFunction.setVisible ()"); - Goshka Tarasov
    • Also, as an option, it really turns out that you are transferring just one function. - binliz