Searching info for GMLib library about news from TWebBrowser in Android and iOS in new version of RAD Studio (HTML access and JavaScript function execution), I have found the TWebBrowserEx class that does all that I need.
This class created by Jun HOSOKAWA is compatible with RAD Studio (from XE5 version -with minor changes- until Seattle 10) and with Appmethod (from 1.14 to 1.17).
The TWebBrowserEx class inherits from TWebBrowser directly (so that will be compatible with all applications developed with this component) adding some nice improvements:
- procedure CallJS: this method does a call to a JavaScript function (with or without params).
- procedure EvaluateJavaScript: this method execute JavaScript code.
- procedure LoadFromStrings: shows the HTML code passed by a string parameter.
- function GetTagValue: function that return the value of any HTML tag.
While it is true that we have in Seattle 10 EvaluateJavaScript method from WebBrowser, it isn’t in previous versions and, also we don’t have a standard way to access to the HTML elements.
Here are some snippets of code to run this class (isn’t difficult transform it to a component):
// creation of object FWebBrowser := TWebBrowserEx.Create(Self); FWebBrowser.Parent := Panel2; FWebBrowser.Align := TAlignLayout.Client; // load an url FWebBrowser.URL := 'http://www.cadetill.com/un-repaso-a-lo-nuevo-de-delphi-10-seattle/'; // put a html code directly FWebBrowser.LoadFromStrings('Hello WebBrowser!', ''); // execute a JavaScript code FWebBrowser.EvaluateJavaScript('alert("EvaluateJavaScript method from WebBrowserEx class!")'); // getting a value from id lat := FWebBrowser.GetTagValue('lat', 'value'); lng := FWebBrowser.GetTagValue('lat', 'value'); ShowMessage(Format('lat/lng clicked: %s/%s', [lat, lng])); // execute a JavaScript function into HTML code FWebBrowser.CallJS('MapSetCenter', ['42.51968735985934', '42.51968735985934']);
In addition, TWebBrowserEx is open source and is hosted on github.
You can download a demo from this link.
See you!
Hello,
Tdcef3 is now compatible with both VCL and FMX libraries.
Is it a great amout of work to update your library and use Tdcef3 ?
Hi Stephane
I can evaluate it for GMLib 2.0, but not for GMLib 1.x
Thanks for the news
Hello,
FWebBrowser.GetTagValue is not work in android platform.
what to do?
You need to ask to the owner of the component. Sorry
How can I enable javascript in TWebView (WebView) for Delphi Berlin