protected void onCreate(Bundle savedInstanceState) {
String javaScript = "javascript:(function(){var%20content=document.getElementsByClassName('entry-content')[0].innerHTML;var%20content2=content.replace(/<p>/,'');var%20endpos=content2.search(/<div%20id/);})()";
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_neugkeiten_rss_item);
Bundle bundle = getIntent().getExtras();
String item_link = bundle.getString("link");
String item_title = bundle.getString("title");
TextView textViewTitle = (TextView) findViewById(R.id.textViewRssItemTitle);
textViewTitle.setText(item_title);
WebView webViewContent = (WebView) findViewById(R.id.webViewNewsContent);
webViewContent.getSettings().setJavaScriptEnabled(true);
webViewContent.loadUrl("file:///android_asset/Resources/rsscontent.html");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}
public void onbuttonclick (View view) {
WebView webViewContent = (WebView) findViewById(R.id.webViewNewsContent);
webViewContent.getSettings().setJavaScriptEnabled(true);
webViewContent.loadUrl("javascript:(function() {var%20content=document.getElementsByClassName('entry-content')[0].innerHTML;var%20content2=content.replace(/<p>/,'');var%20endpos=content2.search(/<div%20id/);var%20content3=content2.slice(0,endpos);var%20content4=content3.replace(/%20%20%20%20/,'');document.body.innerHTML=content4;document.body.style.backgroundColor='#e9e9e9';})()");
}
Hello Everyone,
I am facing an issue: I am trying to load a webpage into my web view and then execute a JavaScript function that removes irrelevant content and changes the background color. On PC, my JavaScript works fine but not in the Android browser or webview. Can anyone help me identify what's wrong with the code?
Using Api-Level 11 and Targeting 17
If anyone knows of a good tutorial on how to download HTML files, I would greatly appreciate it.