Page 1 of 1

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

Posted: Mon Jul 23, 2018 9:23 pm
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;

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

Posted: Tue Jul 24, 2018 12:44 pm
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".