views:

168

answers:

1

Hi dudes,

How can I get the size (chars or Bytes) of a webpage loaded using TWebBrowser? I mean "size" as length of HTML content of a webpage loaded.

Thanks in advance.

+4  A: 

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%5Foleobject.htm

RRUZ