delphi 调用js脚本

function ExecScript(Code,Lang,Func:string):string;

var

script:OleVariant;

begin

script:=CreateOleObject('ScriptControl');

script.Language:=Lang;

script.AddCode(Code);

Result:=script.Eval(Func);

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

Memo2.Lines.Text:=ExecScript(Memo1.Text,'JavaScript','getFullToday()');

end;

function fun(i){

return i*i;

}

str=[1,2,3];

escape("Visit W3School!")

escape("?!=()#%&")

猜你喜欢

转载自www.cnblogs.com/blogpro/p/11452545.html