0

I am using Android's WebView as the rendering engine for a browser. I would like to be able to get an image's title. For example, when browsing to https://www.xkcd.com/327/ on a desktop, mousing over the comic displays the following text: "Her daughter is named Help I'm trapped in a driver's license factory." The source code for the comic is as follows:

<img src="//imgs.xkcd.com/comics/exploits_of_a_mom.png" title="Her daughter is named Help I&#39;m trapped in a driver&#39;s license factory." alt="Exploits of a Mom" />

Using WebView.HitTestResult.getExtra() pulls the src. Does anyone know of a way to get the title?

Soren Stoutner
  • 1,413
  • 15
  • 21
  • you might try WebView.evaluateJavascript(), see http://stackoverflow.com/questions/19788294/how-does-evaluatejavascript-work. This might be challenging if you don't control the web content, but it allows you to run your own javascript code against the DOM and return data. – CSmith Dec 23 '16 at 14:31
  • `WebView.evaluateJavascript()` is an interesting idea. As you point out, implementing it is difficult if you don't control the web content. In my case, I am building a browser that needs to be able to pull an image title from any image on any website and display it in a context menu. – Soren Stoutner Dec 23 '16 at 18:22
  • I added a feature request to the Android project to add this functionality. https://code.google.com/p/android/issues/detail?id=231063 – Soren Stoutner Dec 27 '16 at 19:59

0 Answers0