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';})()");
}
Hi Guys,
I have a problem: I want to load a webpage into my web view and then run a javascript onto it that removes all irrelevant content and redefines the background color. My javascript does work on pc but not in the android browser or in the webview. Do you know whats wrong in the code?
Api-Level 11 Target 17
It would be also great if someone of you knows a good tutorial on how to download html files