user2986634 user2986634 - 1 year ago 310
Android Question

How can I use javascript in TWebBrowser in Delphi XE5 on all platforms (IOS,WIN,ANDROID)?

I want to use

on Android in Delphi XE5 to connect to google maps api.
I wrote my own component which works on WIN platform. I used
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
on Android (execute javaScript in

Is any other solution?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download