Advertisement
TLama

Untitled

May 23rd, 2013
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.27 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, OleCtrls, SHDocVw, MSHTML;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     WebBrowser1: TWebBrowser;
  13.     procedure FormCreate(Sender: TObject);
  14.     procedure Button1Click(Sender: TObject);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21. var
  22.   Form1: TForm1;
  23.  
  24. implementation
  25.  
  26. {$R *.dfm}
  27.  
  28. procedure TForm1.FormCreate(Sender: TObject);
  29. begin
  30.   WebBrowser1.Navigate('http://pastebin.com/raw.php?i=4Gcssd8x');
  31. end;
  32.  
  33. procedure ExecuteJavaScript(WebBrowser: TWebBrowser; const Script: WideString);
  34. var
  35.   HTMLWindow: IHTMLWindow2;
  36.   HTMLDocument: IHTMLDocument2;
  37. begin
  38.   if Supports(WebBrowser.Document, IID_IHTMLDocument2, HTMLDocument) then
  39.   begin
  40.     HTMLWindow := HTMLDocument.parentWindow;
  41.     if Assigned(HTMLWindow) then
  42.     try
  43.       HTMLWindow.execScript(Script, 'JavaScript');
  44.     except
  45.       on E: Exception do
  46.         ShowMessage(Script + sLineBreak + E.Message);
  47.     end;
  48.   end;
  49. end;
  50.  
  51. procedure TForm1.Button1Click(Sender: TObject);
  52. begin
  53.   // shift by 250 pixels to top & left
  54.   ExecuteJavaScript(WebBrowser1, Format('moveByPixel(%d, %d)', [-250, -250]));
  55. end;
  56.  
  57. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement