1. Home
  2. Computing & Technology
  3. Delphi Programming

Get the full HTML from the TWebBrowser component

By , About.com Guide

When using the TWebBrowser component you might want to grab the full HTML source code from the page being displayed by the component. Here's how:

~~~~~~~~~~~~~~~~~~~~~~~~~
uses mshtml;

var
    iall : IHTMLElement;
begin
   if Assigned(WebBrowser1.Document) then
   begin
     iall := (WebBrowser1.Document AS IHTMLDocument2).body;

     while iall.parentElement <> nil do
     begin
       iall := iall.parentElement;
     end;
     memo1.Text := iall.outerHTML;
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Note: HTML goes into a TMemo control named "Memo1".

Delphi tips navigator:
» How to start your favorite application directly from the Delphi IDE
« TForm.Create(?) Nil, Self or Application?

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. TWebBrowser
  6. Get the full HTML from the TWebBrowser Delphi component

©2009 About.com, a part of The New York Times Company.

All rights reserved.