2

how to hide my website header in android webview? I have tried javascript function in my mainactivity.java but not worked, Please hep, Thanks in advance!

This is Im tried

@Override public void onPageFinished(WebView view, String url) { myWebView.loadDataWithBaseURL("javascript:(function() { " + "document.get('header')[0].style.display='none'; " + "})()"); } 
8
  • This is Im tried and what is the result? Commented Sep 4, 2017 at 6:22
  • not working! please help Commented Sep 4, 2017 at 6:30
  • not working! any error messages in logcat? Maybe you are using wrong ID? You didn't show your HTML, so I can't help. Commented Sep 4, 2017 at 6:30
  • no error messages., How to find the correct ID for header? Commented Sep 4, 2017 at 6:33
  • How to find the correct ID for header - You didn't show your HTML, so I can't help. Commented Sep 4, 2017 at 6:34

1 Answer 1

2

hope you have added

mWebView.getSettings().setJavaScriptEnabled(true); myWebView.loadDataWithBaseURL("javascript:(function() { " + "var header = document.getElementById(\"header\"); " + "header.parentNode.removeChild(header);" + "})()"); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.