Page 1 of 1

Get result data from a JS function

Posted: Wed Nov 14, 2018 10:36 pm
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

Re: Get result data from a JS function

Posted: Thu Nov 15, 2018 8:13 am
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.