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.

Incompatible types: 'string' and 'procedure, untyped pointer or untyped param

Post Reply
Laertes
Posts: 29
Joined: Fri Apr 27, 2018 1:27 pm

Incompatible types: 'string' and 'procedure, untyped pointer or untyped param

Post by Laertes »

Hello !
I'm testing how to get the contents of a label. Running this command on the google chrome console did work, but I tried to put in the component did not work. What am I doing wrong?

Code on console

Code: Select all

document.getElementsByClassName("label")[3].innerHTML;

Code in component

Code: Select all

procedure TMiniBrowserFrm.Button4Click(Sender: TObject);
var
  X: String;
begin
  X:=chromium1.browser.MainFrame.ExecuteJavaScript('document.getElementsByName("label")[3].innerHTML;','about:blank',0);
end;
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Incompatible types: 'string' and 'procedure, untyped pointer or untyped param

Post by salvadordf »

It's not possible to get the JavaScript results in that way. You need to register a JavaScript extension and send the results back to the main browser process.

The JSExtension demo has all the code you need. Run it, right-click on the web page and select "Visit DOM in JavaScript".
Post Reply