Delphi: procedure TForm1.FormCreate(Sender: TObject); begin // Binding ScriptGate to WebBrowser and setting the scheme delphi // The scheme is also specified on the JavaScript side // Same as file :, JavaScript: etc. ScriptGate := TScriptGate.Create(Self, WebBrowser1, 'delphi'); end;
// Call helloJS () JavaScript. // You can also retrieve the return value using an anonymous function. procedure TForm1.Button1Click(Sender: TObject); begin FScriptGate.CallScript( 'helloJS()', procedure(const iResult: String) begin ShowMessage(iResult); // Show return value end ); end;
// Execute arbitrary JavaScript // You can also retrieve the return value using an anonymous function. procedure TForm1.Button1Click(Sender: TObject); begin FScriptGate.Eval( 'document.getElementsByTagName("html")[0].outerHTML', procedure(const iResult: String) begin ShowMessage(iResult); // Show return value end ); end;
// It is a method published in JavaScript and is called from JavaScript. procedure TForm1.HelloDelphi; begin ShowMessage('Hello, Delphi!'); end;
----------------------------------------------
Delphi4Linux Delphi三层/FireDAC 技术群:734515869 http://www.cnblogs.com/rtcmw
function TfrmMain.LoadPlantinfo: string; var RemoteServer: TServerMethods1Client; JsonData: String; begin try if not Assigned(ClientModule1) then ClientModule1 := TClientModule1.Create(nil); RemoteServer := TServerMethods1Client.Create(ClientModule1.DSRestConnection1); JsonData := RemoteServer.GetPlantinfo(); if JsonData <> '' then begin Result := JsonData; end; except end; end;
----------
<script type="text/tiscript">
function self.ready() { var param = view.LoadPlantinfo(); GetPlantInfo(param); //填充表格 }
function GetPlantInfo(parameters){ var records = JSON.parse(parameters); var vlist = $(table); vlist.value = records; } </script>
----------------------------------------------
-