Hi,
How can I evaluate javascript function with FMXChromium and return results.
The sample provided JSEval is available only for VCL applications...
FMX.TWebbrowser from embarcadero ha too many bugs and is unreliable.
I have posted the same question on GitHub, sorry for duplicate
Thank you in advance,
Pavel
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
FMX Javascript evaluation
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: FMX Javascript evaluation
Hi,
You need to mix the SimpleFMXBrowser and JSEval demos into one but please, if you haven't read the following web pages take a few minutes to read them :
https://www.briskbard.com/index.php?lang=en&pageid=cef
https://bitbucket.org/chromiumembedded/ ... gration.md
Read the code comments in the SimpleFMXBrowser and JSEval demos too because adding a TChromium component to an FMX app requires a few steps and the JavaScript demos require inter-process messages and Windows messages.
Use the SimpleFMXBrowser demo as the template for your application and add what you need from the JSEval demo.
You will probably need all this :
If you need to show the final results in the user interface then you will need to send a Windows message from the TChromium.OnProcessMessageReceived event. The JSEval demo uses MINIBROWSER_SHOWTEXTVIEWER to show the results in a child form.
As you can see, all the FMX demos use a modified IFMXApplicationService in the uFMXApplicationService.pas file.
Modify the TFMXApplicationService.HandleMessage to add your custom Windows messages.
You need to mix the SimpleFMXBrowser and JSEval demos into one but please, if you haven't read the following web pages take a few minutes to read them :
https://www.briskbard.com/index.php?lang=en&pageid=cef
https://bitbucket.org/chromiumembedded/ ... gration.md
Read the code comments in the SimpleFMXBrowser and JSEval demos too because adding a TChromium component to an FMX app requires a few steps and the JavaScript demos require inter-process messages and Windows messages.
Use the SimpleFMXBrowser demo as the template for your application and add what you need from the JSEval demo.
You will probably need all this :
- Use the TChromium.OnBeforeContextMenu and TChromium.OnContextMenuCommand events and copy their code from Chromium1BeforeContextMenu and Chromium1ContextMenuCommand.
- Copy RenderProcessHandler_OnProcessMessageReceivedEvent and assign it to GlobalCEFApp.OnProcessMessageReceived
- Copy ParseEvalJsAnswer
- Use the TChromium.OnProcessMessageReceived to receive the results. Copy Chromium1ProcessMessageReceived.
If you need to show the final results in the user interface then you will need to send a Windows message from the TChromium.OnProcessMessageReceived event. The JSEval demo uses MINIBROWSER_SHOWTEXTVIEWER to show the results in a child form.
As you can see, all the FMX demos use a modified IFMXApplicationService in the uFMXApplicationService.pas file.
Modify the TFMXApplicationService.HandleMessage to add your custom Windows messages.
Re: FMX Javascript evaluation
Dear Salvador,
First of all I want to thank you for your fast reply.
I will try your suggested solution and I will let you know if any problem arise.
Thanks again,
Pavel
First of all I want to thank you for your fast reply.
I will try your suggested solution and I will let you know if any problem arise.
Thanks again,
Pavel