Question

I want to use TWebBrowser on Android in Delphi XE5 to connect to google maps api. I wrote my own component which works on WIN platform. I used Twebbrowser and IHTMLDocument2. For example :

if Self.Document as IHTMLDocument2<>nil then
  with TWebBrowser(Self).Document as IHTMLDocument2 do
    with ParentWindow do
      execScript(aScript, 'JavaScript');

Is Any chance to run something similar in TWebbrowser on Android (execute javaScript in TWebBrowser)?

Is any other solution?

Was it helpful?

Solution

By the looks of it according to the documentation of the Android WebView, which I currently assume (without having resource to the source) to be behind TWebBrowser, you'd need to pull out the underlying Android WebView and call its add JavascriptInterface() method (documentation here).

Whether anyone's already done that, I don't know. But that looks to be the requirement. The next step is working out how to access the underlying WebView. I'd imagine that is tucked away in the Android implementation unit for the web browser, so that will be tricky, and may require you to modify the source files.

Anyway, hopefully that gets you started.

OTHER TIPS

I propose to You to use something like:

 TWebBrowser.Document AS IHTMLDocument2 

and then check OnKeyDown event what is the caption of all inputs objects in DOM.

Hope it helps... I'm not the God of XE5 :-)

I saw an example that wrote the static html to a local file, then loaded the local file.

WebBrowser1.Navigate('file://MyFile.html')

If you find a solution that works in iOS and Android, I'd love to hear about it.

Struggling with the same issue right now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top