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.

Capture JavaScript function return

Post Reply
EdsonAlves
Posts: 7
Joined: Sun Jan 28, 2018 12:38 pm

Capture JavaScript function return

Post by EdsonAlves »

Is it possible to execute an asynchronous javascript function and play the return on a promisse and how much does the resolver function capture its return in delphi?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Capture JavaScript function return

Post by salvadordf »

Hi,

You can execute customized JavaScript code using TChromium.ExecuteJavaScript. That code can call any kind of JavaScript functions, including registered extensions.

Those extensions are Delphi functions but they are executed in the render process so you will have to send the results to the main browser process using TCefv8ContextRef.Current.Browser.SendProcessMessage. That message is received in the TChromium.OnProcessMessageReceived event.

All this is explained in the code comments added to the JSRTTIExtension and JSExtension demos.
Post Reply