Using Tidhttp with Twebbrowser

I use the tidhttp control to speed up loading a web page in Twebbrowser. URL navigation is slow, so I don't use it ( WebBrowser1.Navigate('some_url_here')). Here is how I do it:

procedure TForm1.Button2Click(Sender: TObject);
  procedure LoadHtmlIntoBrowser(var WB: TweBbrowser; const HTMLString: string);
  var
    v: OleVariant;
    HTMLDocument: IHTMLDocument2;
  begin
    WB.Navigate('about:blank');
    while WB.ReadyState < READYSTATE_INTERACTIVE do
      forms.Application.ProcessMessages;

    if Assigned(WB.Document) then
    begin
      HTMLDocument := WB.Document as IHTMLDocument2;
      v := VarArrayCreate([0, 0], varVariant);
      v[0] := HTMLString;
      HTMLDocument.Write(PSafeArray(TVarData(v).VArray));
      HTMLDocument.Close;
    end;
    forms.Application.ProcessMessages;
  end;

var
  str:string;
begin
  str:=idhttp1.Get('http://localhost/myhome.html');
  LoadHtmlIntoBrowser(WebBrowser1,str);
end;

idHTTP, html , Webbrowser. - (XAMPP). , , , , html , , , , "twopage.html" . " ", "<html>twopage.html</html>", , html .

myhome.html

<html>
  <head></head>
  <body><h1>My home</h1><a href="twopage.html"></a></body>
</html>

The other webpage, "twopage.html" contains

<html>
  <head></head>
  <body><h1>Another Webpage</h1></body>
</html>
+5
1

<base> HTML, -, url, URL-.

+7

All Articles