关于网页源码显示。。。(20分)

  • 主题发起人 主题发起人 fullstrong
  • 开始时间 开始时间
F

fullstrong

Unregistered / Unconfirmed
GUEST, unregistred user!
用Twebbrower编写浏览器,通过何语句能够调用计事本显示浏览网页的源码呢?象右键中的查看源文件功能一样。
 
没有人知道了吗!
 
也许是因为分太少了:)
 
yes.加到200分我告诉你。哈哈
 
procedure TForm1.SaveHTMLSourceToFile(const FileName: string;
WB: TWebBrowser);
var
PersistStream: IPersistStreamInit;
FileStream: TFileStream;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
FileStream := TFileStream.Create(FileName, fmCreate);
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
if FAILED(SaveResult) then
MessageBox(Handle, 'Fail to save HTML source', 'Error', 0);
finally
{ we are passing soReference in TStreamAdapter constructor,
it is our responsibility to destroy the TFileStream object. }
FileStream.Free;
end;
end;

pocedure TForm1.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
SaveHTMLSourceToFile(SaveDialog1.FileName, WebBrowser1);
end;
存成文件后再调写字板打开就可以了
 
由于我是小菜鸟,分用的差不多了,请大家将就以下吧!
 
接受答案了.
 
后退
顶部