0

I am using the webview as following

WebView webView = (WebView) this.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://m.facebook.com");

It loads the page fine. Now I am trying to add a line head section of the page before it renders in the web view. e.g.

<style>.test{color:red}</style>

is it possible to add. if yes then how??

1 Answer 1

1

this can be done using evaluateJavascript

webView.evaluateJavascript("javascript: document.getElementById('header').setAttribute('style','background-color: red;') ", new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
  //in case you have some return value from your script
}
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.