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
Here are some nifty WebBrowser related tips and tricks:


Comments
¿Como puedo impedir que una pagina web cierre el componente TWebBrowser?
How to disable HTML closing of a TWebBrowser?
Thanks
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;
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.
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 ?