DCEF3 与JS交互
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cefvcl,ceflib; type //这里建议用class 不建议用class(TThread) 不然有些地方要报错 TMyExtension = class(TThread) // or just class, (extension code execute in thread) public class function _geta(test : string):string; end; type TCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn) protected procedure OnWebKitInitialized; override; end; type TForm1 = class(TForm) Chromium1: TChromium; private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} class function TMyExtension._geta(test : string): string; begin Result := test; end; procedure TCustomRenderProcessHandler.OnWebKitInitialized; begin TCefRTTIExtension.Register('JS_DELPHI', TMyExtension); end; initialization CefRenderProcessHandler := TCustomRenderProcessHandler.Create; end. (* <script> alert( JS_DELPHI._geta('Test Call') ); </script> *)
转到:http://www.cnblogs.com/Delphi-Farmer/p/4103708.html