P
peacekeeper
Unregistered / Unconfirmed
GUEST, unregistred user!
如果不含frame的网页,可以显示源代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, OleCtrls, SHDocVw,mshtml;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
webbrowser1.Navigate('http://202.114.98.12/book/');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
all:IHTMLElementcollection;
doc:IHTMLDocument2;
item:OleVariant;
begin
doc:=webbrowser1.document as ihtmldocument2;
all:=doc.all;
item:=all.item(0,varEmpty);
Memo1.Clear;
memo1.Lines.Add(item.innerhtml);//item.innerhtml就是源文件内容
end;
end.
但是,<b>如果含Frame呢???</b>
如果用
TAROBJ:OLEVARIANT;
....
TarOBJ := WebBrowser1.OleObject.Document.Frames.Item(1).Document;
我接不下去。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, OleCtrls, SHDocVw,mshtml;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
webbrowser1.Navigate('http://202.114.98.12/book/');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
all:IHTMLElementcollection;
doc:IHTMLDocument2;
item:OleVariant;
begin
doc:=webbrowser1.document as ihtmldocument2;
all:=doc.all;
item:=all.item(0,varEmpty);
Memo1.Clear;
memo1.Lines.Add(item.innerhtml);//item.innerhtml就是源文件内容
end;
end.
但是,<b>如果含Frame呢???</b>
如果用
TAROBJ:OLEVARIANT;
....
TarOBJ := WebBrowser1.OleObject.Document.Frames.Item(1).Document;
我接不下去。