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.

Get result data from a JS function

Post Reply
AndreMurta
Posts: 6
Joined: Thu Apr 12, 2018 1:51 am

Get result data from a JS function

Post by AndreMurta »

Hi all,

After take a look at the demo applications, I realized it's very simple to send data from my Delphi program to a JS script located at the webpage in use by the component. What I would like to have is actually the opposite. I would like to load a page with a form in it, a button element in the form could be used to start a JS function that builds a JSON text from the form's other elements. I would like to have this JSON text in a string variable after the JS function finishes its execution.
What I'm doing to have this functionality at this point, is to adapt the code present at the "JSDialogBrowser" demo, changing the functionality of the JS "alert()" function to something like the code below:

Code: Select all

JSDIALOGTYPE_ALERT: MyVar := FMessageText;
Is there a "smarter" way to achieve such functionality? Could you give me some indications about how to have it?

Thanks
User avatar
salvadordf
Posts: 4078
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Get result data from a JS function

Post by salvadordf »

Hi,

The JSDialogBrowser demo was created to show how to replace the default message forms generated by CEF3 to show the results of JavaScript functions like "alert".

If you need to send some results from JavaScript to Delphi you can use the code from the JSRTTIExtension or JSExtension demos.

For more information about JavaScript integration read this :
https://bitbucket.org/chromiumembedded/ ... gration.md

All the code examples in that web page have a CEF4Delphi demo to show you how to implement them in Delphi.
Post Reply