Manually Writing the HTML in TWebBrowser
EDIT: Look at Jorn's approach.
My theory is that because the links in the HTML are relative, the browser can't load any of it. I have switch from pa开发者_开发知识库ssing 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.
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;
There are also some good examples at delphi.about.com
And some more complex examples at www.delphidabbler.com
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.
精彩评论