Injecting JavaScript into a WebView

android call java function

final WebView webview = (WebView)findViewById(;
/* JavaScript must be enabled if you want it to work, obviously */

/* WebViewClient must be set BEFORE calling loadUrl! */
webview.setWebViewClient(new WebViewClient() {
    public void onPageFinished(WebView view, String url)
        webview.loadUrl("javascript:(function() { " +
                "document.getElementsByTagName('body')[0].style.color = 'red'; " +


By admin-powenko

Dr. Powen Ko is a teacher and CEO on LoopTek LLC, and like to teaching. if you need to class, please let PowenKo know, he will love to service and sharing. LoopTek web site is

Leave a Reply