0

I'm displaying an HTML document using a WebView. The HTML document is contained in an HTML string. I pass the HTML string to the WebView by using its loadDataWithBaseURL() method, as follows (I got it from this answer):

webView.loadDataWithBaseURL("fake://not/needed", getResources().getString(R.string.htmlString), "text/html", "utf-8", "");

Now, I'd like to show the HTML document contained in that HTML string starting not at the document's beginning, but at a given HTML anchor contained in the HTML string.

Can I do that with webView.loadDataWithBaseURL()? Or more gnerally: is there any method to show local content on a WebView starting at an anchor?

Community
  • 1
  • 1
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • 1
    I don't know if it works with that WebView method but as a workaround you could inject some JavaScript that gets executed when the page is loaded and that sets the location to "#YourAnchor". – tiguchi Oct 10 '13 at 23:00
  • @NobuGames Thanks! Actually, I don't know JavaScript, and anyway I would prefer a cleaner solution if it exists... – Luis Mendo Oct 10 '13 at 23:02

0 Answers0