1. Home
  2. Computing & Technology
  3. Delphi Programming
photo of Zarko Gajic

Zarko's Delphi Programming Blog

By Zarko Gajic, About.com Guide to Delphi Programming since 1998

WebBrowser to the MAX

Thursday May 27, 2004
TIPS :: TWebBrowser component provides access to the Web browser functionality from your Delphi apps (to allow you to create a customized Web browsing application or to add Internet, file and network browsing, document viewing, and data downloading capabilities to your applications).

Here are some nifty WebBrowser related tips and tricks:

  • Capturing a Screen Shot of a TWebBrowser Content (Web Page) in Delphi
  • Reset the TWebBrowser Delphi control to an Empty (Blank) Page
  • How to Execute a JavaScript Code on a TWebBrowser Document
  • Get the Url of a Hyperlink when the Mouse moves Over a TWebBrowser Document
  • How to enable editing of a document in TWebBrowser
  • Get the full HTML from the TWebBrowser component
  • Using TWebBrowser to preview (and print) Microsoft Word documents
  • How to check if a document in a TWebBrowser is located on a local drive
  • How to locate and highlight a string in a TWebBrowser
  • How to save a web page as HTML or MHT
  • How to load HTML directly to a WebBrowser
  • How to append (add) HTML directly to a WebBrowser document
  • How to call the Find dialog in WebBrowser
  • How to call the View Source dialog in WebBrowser
  • How to print a document/page in a TWebBrowser
  • From ADO Query to HTML
  • How to disable Context menu in a TWebBrowser
  • How to open a web site or a .htm file with the default web broswer in a NEW window
  • Comments

    June 2, 2007 at 1:12 pm
    (1) Adrian says:

    ¿Como puedo impedir que una pagina web cierre el componente TWebBrowser?

    How to disable HTML closing of a TWebBrowser?

    Thanks

    August 8, 2007 at 4:06 pm
    (2) Jen Armstrong says:

    I found that the example in the “Get the full HTML from the TWebBrowser Delphi component” article worked, but stripped out some quotations (although, I’m not sure why). I found the following alternative code on http://xml.defined.net/samples/delphi/webbrowser.html which worked much better.

    function GetDocumentContents(WebBrowser : TWebBrowser) : String;
    var
    Stream:TStringStream;
    StreamAdapter:IStream;
    begin
    with (WebBrowser.Document as IPersistStreamInit) do
    begin
    Stream := TStringStream.Create('’);
    try
    StreamAdapter := TStreamAdapter.Create(Stream,soReference);
    try
    Save(StreamAdapter,true);
    Result := Stream.DataString;
    finally
    StreamAdapter := nil;
    end;
    finally
    Stream.Free();
    end;
    end; { with }
    end;

    August 10, 2007 at 11:48 am
    (3) Koen Van de moortel says:

    Hi Zarko,

    I found out that TWebbrowser also works fine to view RTF files.
    Only, when I open one (MyWebbrowser.navigate(’Myfile.rtf’) Windows prompts me if it is safe to open this kind of file, and there is always a header that I don’t like.
    Do you know how to get rid of the prompt and the header? Thanks in advance.

    December 19, 2007 at 6:22 am
    (4) Andrea Losacco says:

    I have a problem with twebbrowser component. If compiled by delphi6 all is ok. But if compiled by delphi2006 twebbrowser doesn’t work well. no error if I use .navigate method (but the page is not displayed), an eoleexception error if I use a .refresh method. Any suggestion ?

    Leave a Comment

    Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

    Explore Delphi Programming

    More from About.com

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

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

    All rights reserved.