Page 1 of 1

Get input value

Posted: Wed Oct 03, 2018 12:11 am
by Laertes
Hello !
I ran a test running the command in the google chrome console and returned the input value typed. How do I pass this value to a string?

I used this command in google chrome

Code: Select all

document.getElementById("login-email").value
In delphi without success

Code: Select all

var S: String 
emailLogin:= chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("email").value;','about:blank', 0);
Error:
uMiniBrowser.pas(4804): E2010 Incompatible types: 'string' and 'procedure, untyped pointer or untyped parameter'

Re: Get input value

Posted: Wed Oct 03, 2018 7:03 am
by salvadordf
Chromium doesn't allow to execute and assign JavaScript values like that.
You need to use a special JavaScript function that executes Delphi code. That JavaScript function is called "JavaScript extension".

Read this :
https://bitbucket.org/chromiumembedded/ ... gration.md

Each code example in that document has a Delphi demo in the "demos\JavaScript" directory. Many demos in that directory do what you need.

Check out the JSExtension demo to see how to get a string value from the web page and send it to Delphi.