tags:

views:

160

answers:

4

EDIT: Look at Jorn's approach.
I am using the strategy suggested here: http://cc.embarcadero.com/Item/23992 to get my HTML in the TWebBrowser, but I get a bunch of JavaScript errors when the page loads. If I click yes enough times I can see a page with no formatting and I'm guessing the page does nothing.

My theory is that because the links in the HTML are relative, the browser can't load any of it. I have switch from passing the URL, 'about:blank' to the navigate function, to passing the servers home page - in the hopes that some internal mechanism will be able to generate full paths, but no luck.

Any one successfully been able to manually write HTML to the TWebBrowser.

+3  A: 

Since the HTML is not coming from a live URL, you need to include a <base href=...> tag in the HTML itself so relative links can be resolved correctly.

Remy Lebeau - TeamB
This is probably exactly what I needed, but I went and got it done another way. So without checking up on it I'll mark this as the answer.
nomad311
+1  A: 

I usually use this approach:

//OnFormCreate:
begin
  WebBrowser.Navigate('about:blank');
end;

//OnButtonClick:
var
  Doc: Variant;
begin
  Doc := WebBrowser.Document;
  Doc.Clear;
  Doc.Write(Memo.Text);
  Doc.Close;
end;
Jørn E. Angeltveit
Yup, thats what I ended up with, but you will probably end up seeing the same type of problems I did this way. +1 b/c this is 'better' than the method described in that article.
nomad311
+1  A: 

Some useful resources:

Zarko Gajic have a great collection of snippets at delphi.about.com

Jørn E. Angeltveit
A: 

Some useful resources:

Peter Johnson has a bit more complex examples at www.delphidabbler.com

Jørn E. Angeltveit