Executing JS in TWebBrowser

穿精又带淫゛_ 提交于 2019-12-13 04:59:17

问题


I take http://www.foxbase.ru/delphi/javascript-na-delphi.htm worked example and trying to execute my own js code. Some corrections and its simly like this : http://shadow-core.com/ShadowJS.pas

Firstly , i dont know where is problem... Cuz , in source code in example, we simply use:

  js:=TDelphiJS.Create;
  js.LoadFromURL('http://vbulletin_forum.ru/clientscript/vbulletin_md5.js?v=371');
  js.DeclareVariable('mypassword');
  js.DeclareVariable('');
  js.DeclareVariable('');
  js.DeclareVariable('');
  js.Execute('md5hash');
  ShowMessage(js.GetVariable(2));
  js.free;

I use in my unit smth like this :

js:=TShadowJS.Create;
 js.LoadFromURL('http://shadow-core.com/dev/col/test.php');
 js.Execute('R()');
 Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_id'));
 Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_cr'));
 Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_76'));
 Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_86'));
 Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_md'));

And my js code are not executing , only default values like this:

0
0
1

By the way , if i make event on another button

procedure TForm1.Button2Click(Sender: TObject);
begin
    Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_id'));
    Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_cr'));
    Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_76'));
    Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_86'));
    Form1.Memo1.Lines.Add (js.GetVariable('TS016c63b6_md'));
end;

i got result that i need.:

ada4857db7445f789aaacaccdfe69aa6:knjn:W0AR1OiN:287517631
w0b5cc99da3d7a58590359w39b2000w1546f47b90000w3d7a58590359f69ee455fa1a72039b20
9f5172f23c74w78bc586fd3109c321
1

Thats question , how to make twebbrowser executing and returning values that i need momentaly , without form's events?

来源:https://stackoverflow.com/questions/27081532/executing-js-in-twebbrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!