DCEF3 - Delphi Chromium Embedded - The Link Between Javascript and Application Code

I am using DCEF3, version 24038bd3a600, and I will need to communicate between the Javascript code in the browser and the Delphi application code. I know how this can be done from Delphi and Javascript code using the Framework ExecuteJavascript method, but what about the opposite (from Javascript to Delphi / application code)? I did not find this situation in demos / examples (GUIclient, in particular ...).

+4
source share
2 answers

There is a guiclient demo as official source code . See the main.pas file.

The following is the class extension code:

class function TTestExtension.hello: string;
begin
  Result := 'Hello from Delphi';
end;

:

TCefRTTIExtension.Register('app', TTestExtension);

HTML-:

<script>
alert ( app.hello() );
</script>

:

crm.Browser.MainFrame.ExecuteJavaScript('alert ( app.hello() );', 'about:blank', 0);
+2

- OnJSDialog/OnConsoleMessage , Alert/log JS, - . delphi , . (, ). delphi , , .

+1

Source: https://habr.com/ru/post/1547697/


All Articles