Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

delphi - Manually Writing the HTML in TWebBrowser

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...