Hallo,
wenn Du
base zum
HTML-FrameString hinzufügst, funktioniert es damit:
Delphi-Quellcode:
procedure TForm1.LoadHTMLString(WebBrowser: TWebBrowser; HTMLCode:
String);
var
sl: TStringList;
ms: TMemoryStream;
flag : Olevariant;
begin
WebBrowser.Navigate('
about:blank', flag,flag,flag,flag);
while WebBrowser.ReadyState < READYSTATE_INTERACTIVE
do
Application.ProcessMessages;
if Assigned(WebBrowser.Document)
then
begin
sl := TStringList.Create;
try
ms := TMemoryStream.Create;
try
sl.Text := HTMLCode;
sl.SaveToStream(ms);
ms.Seek(0, 0);
(WebBrowser.Document
as IPersistStreamInit).Load(TStreamAdapter.Create(ms));
finally
ms.Free;
end;
finally
sl.Free;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var frame1, frame2, frame3,
base,
//<------ ! !
newhtml :
String;
const newframeset = '
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN >'+#13#10
+'
<META http-equiv= Content-Type content= text/html; charset=iso-8859-1 >'+#13#10
+'
<HTML> <HEAD> <TITLE>test</TITLE>'+#13#10
+'
</HEAD><base href="%s">'+#13#10
//<------ ! !
+'
<FRAMESET BORDER= 1 COLS= 191,609,* >'+#13#10
+'
<FRAME NAME= navigation ID= navigation FRAMEBORDER= 1 NORESIZE= NORESIZE SCROLLING= NO SRC= %s >'+#13#10
+'
<FRAMESET BORDER= 1 ROWS= 60,* > '+#13#10
+'
<FRAME NAME= statusbar ID= statusbar FRAMEBORDER= 1 NORESIZE= NORESIZE SCROLLING= NO SRC= %s >'+#13#10
+'
<FRAME NAME= mainframe ID= mainframe FRAMEBORDER= 1 NORESIZE= NORESIZE SCROLLING= NO SRC= %s >'+#13#10
+'
</FRAMESET>'+#13#10
+'
<NOFRAMES> Ihr Browser kann diese Seite leider nicht anzeigen. </NOFRAMES>'+#13#10
+'
</FRAMESET>'+#13#10
+'
</HTML> ';
begin
frame1 := '
test.html';
frame2 := '
test.html';
frame3 := '
test.html';
base := ExtractFilePath(ParamStr(0));
//<------ ! !
newhtml := format( newframeset, [base,frame1,frame2,frame3]);
LoadHTMLString(WebBrowser1,newhtml);
end;
kA ob das mit document.write funktioniert
, ich hab es nicht getestet.