随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

问题来源: http://www.cnblogs.com/del/archive/2008/04/02/1131232.html#1133889

答案: WebBrowser1.OleObject.Document.ParentWindow.变量名;


譬如有这样一个页面(lancernig 举的例子), 如何提取其中的 pvs 呢:
<html> <head> <title>测试页</title> </head> <body> ... </body> </html>

假定是把页面保存在 'c:\temp\test.htm', 测试代码如下:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  WebBrowser1.Navigate('c:\temp\test.htm');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
begin
  {提取 smoneys}
  s := WebBrowser1.OleObject.Document.ParentWindow.smoneys;
  ShowMessage(s);

  {提取 pvs}
  s := WebBrowser1.OleObject.Document.ParentWindow.pvs;
  ShowMessage(s);
end;

end.

posted on 2008-04-02 10:54  万一  阅读(...)  评论(...编辑  收藏