1

I use webview.loadurl(URL) to download a webpage to my WebView. Is it possible to replace some strings in the webpage while downloading?

user1443721
  • 1,110
  • 2
  • 14
  • 33
  • What do you mean by replacing strings in the webpage while downloading? You can't do that. Android doesn't support that to prevent people from stealing passwords or important info if a user writes that in the webView. But what you can do is building an html string to show it in your webView. – Hussein El Feky Aug 18 '15 at 18:54
  • I followed this example http://stackoverflow.com/questions/19518950 to manipulate HTML content. One problem with is that the onPageFinished() is not called after inner loadUrl() is done. – user1443721 Aug 18 '15 at 19:58
  • Use a http component to download the page. Manupilate it. Load in WebView. – greenapps Aug 18 '15 at 20:27
  • Use a http component to download the page is good to the first page. if users click a link in the page, the next page will be loaded to the WebView automatically. We have no chance to use a http component to download the page. – user1443721 Aug 19 '15 at 04:10

1 Answers1

0

You can do it in Javascript and load it using the loadData method with the prefix "javascript:". For example, loading "javascript:window.alert('Hello');" will show a hello message. You can parse the DOM and replace strings instead of the alert message.

MV1
  • 64
  • 5