Android Question javascript in webview for skip images (without image placeholders)

GERSON PINTO

Member
Licensed User
Hello!
Initially I used the code:
B4X:
WebView1.GetSettings.SetLoadsImagesAutomatically(False)

Images are not actually displayed but the image name appears in its place.
Searching the internet I found the following code in javascript that seems to solve the problem but I do not know how to implement it:

source:https://stackoverflow.com/questions/6856522/how-to-force-webview-to-skip-images

B4X:
webView.loadUrl("javascript:(function(){ var imgs=document.getElementsByTagName('img');"+
                        "for(i=0;i<imgs.length;i++) { imgs[i].style.display='none'; } })()");

Could someone tell me how to implement this function in B4X or another way to do this? Thanks!
 

Brandsum

Well-Known Member
Licensed User
Try this
B4X:
Sub WebView_PageFinished (Url As String)
    WebViewExtras.ExecuteJavascript("for(i=document.images.length-1;i>=0;i--) { document.images[i].remove() }")
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…