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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

the moment of updating the field value on the browser form

Post Reply
Isaev
Posts: 4
Joined: Tue Apr 22, 2025 8:57 am

the moment of updating the field value on the browser form

Post by Isaev »

Hi,

We have an extension with two functions:
- One sets a value to a form field
- The other reads values from the form

We set the value like this:

Code: Select all

Chromium.Browser.MainFrame.ExecuteJavaScript(
  Format('cim_extension.formvalue_set("%s", "%s");', [AProdatName, AValue]),
  '', 0
);
In the JSExtensionAfterExecute handler:

Code: Select all

if (name = 'formvalue_set') then
begin
  // Read values
  Chromium.Browser.MainFrame.ExecuteJavaScript('cim_extension.formvalues_get();', '', 0);
end;

if (name = 'formvalues_get') then
begin
  // Output the result — but the field is still empty! (even though it appears correct visually)
  
end;
However, if we trigger the same reading a bit later (e.g., from a popup menu), everything works correctly!

So — after which event is the field actually updated?
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: the moment of updating the field value on the browser form

Post by salvadordf »

Hi,

I'm not a JS expert but I would try adding an event listener.
You can also try sending a process message from the extension to the main process after setting the new value.
Post Reply