开发者

Getting size of a webpage with TWebBrowser in Delphi

How can I get the size (chars or Bytes) of a webpage loaded using TWebBrowser? I mean "size" as length of HTML content 开发者_StackOverflow中文版of a webpage loaded.

Thanks in advance.


you must use the Document.FileSize property wich returns the size of the html document in bytes.this property returns the file size as a string. keep in mind It will throw an exception if no page is loaded or if the file is not available in the cache. This means that if the document headers request that the file is not cached then calling FileSize will throw an exception.

Try this example:

uses
MSHTML; //the IHTMLDocument2 interface is here

procedure TForm1.WebBrowser1NavigateComplete2(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);    
var
Size : WideString;
begin
 Size:=(WebBrowser1.Document as IHTMLDocument2).FileSize;
 ShowMessage(Size);
 end;

for more info you can read this link http://www.cryer.co.uk/brian/delphi/twebbrowser/twebbrowser_oleobject.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜