Inject JavaScript into Webview to modify remote html element

0

I have a app that only contains a webview . It shows a page (mine) that has a textarea. I want to be able to inject some code lines javascript to modify that element when I click on the "back" key. Here I show what I have so far (which unfortunately does not work):

@Override
public boolean onKeyDown(int keyCode, KeyEvent event){

    if(keyCode == KeyEvent.KEYCODE_BACK){
        mWebview.loadUrl("javascript:(getElementsByTagName('textarea').style.background='blue')");
    }

    return super.onKeyDown(keyCode, event);
}

It only works if I put:

 "javascript:(alert('Se activó el alert');)"

But nothing more. Is it possible to access, by means of js local , an element html externo and modify it?

    
asked by Cristian Annese 18.07.2016 в 19:53
source

0 answers