Autor Beitrag
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 26.04.08 16:06 
hallo,

ich möchte eine seite aus einem memo in einer twebbrowser-komponente anzeigen lassen. wie geht das?
weitere frage, auch zu twebbroser:
wie kann ich im twebbrowser ein javascript ausführen?
noch eine frage: auf dieser html seite, die ich aus dem memo lade, befindet sich ein button. kann der irgendwie geklickt werden (automatisch)?


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Sa 26.04.2008 um 18:30
<TargeT>
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 59

Win XP, Win 98
Delphi 7
BeitragVerfasst: Sa 26.04.08 19:37 
Also wie du die Seite direkt aus dem Memofeld laden kannst ka^^

Aber du könntest die Daten zuerst aus der Memo in einer Datei zb: index.html speichern, dann lässt du den WebBrowser die Seite von der index.html laden, das machste so WebBrowser1.Navigate(ExtractFilePath(Paramstr(0))+'index.html'); .

Button´s kann man auch automatisch drücken lassen, da gibts aber Unterschiede kommt drauf an um was für einen Button es sich handelt, am besten sagste mal um was für einen Button es sich handelt.

lg Target
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Sa 26.04.08 20:00 
muss da nicht ein "File:/// vor?!
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 26.04.08 20:19 
einfach ein button
übrigens das einzige auf dieser html seite
Einloggen, um Attachments anzusehen!
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Sa 26.04.08 20:38 
Nein, es muss kein File:/// vor. TWebbrowser basiert auf dem IE und der kennt auch diese Methode. Firefox übrigens auch, nur wandelt der das im Gegensatz zu IE in ein file:/// um. Übrigens muss man die Datei nicht davor zwischenspeichern, man kann dem Webbrowser auch direkt einen Inhalt zuweisen.


Zuletzt bearbeitet von Jakob_Ullmann am Sa 26.04.08 20:51, insgesamt 1-mal bearbeitet
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 26.04.08 20:47 
und wie? das war ja meine frage...
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Sa 26.04.08 20:55 
Das hab ich mal bei SwissDelphiCenter gefunden, bitte um einen Hinweis, falls ich das hier nicht angeben darf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TForm1.WB_LoadHTML(WebBrowser: TWebBrowser; HTMLCode: string);
var
  sl: TStringList;
  ms: TMemoryStream;
begin
  WebBrowser.Navigate('about:blank');
  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;


Aber beim SwissDelphiCenter findest du tausende von Funktionen für den TWebbrowser.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 26.04.08 22:49 
Moin!

Bitte erstelle für jede deiner Fragen ein separates Topic, da die Diskussion mehrerer Fragen in einem Topic für gewöhnlich für Verwirrung und Durcheinander sorgt. Eigentlich sollte das Problem laut Thread-Titel gelöst sein. Wenn hier jetzt noch die anderen Fragen angegangen werden, mache ich den Thread zu. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
gsl
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 05.05.08 16:21 
Der Code aus SwissDelphiCenter nicht funktioniert seit Jahren. Diese Funktion ladt einige HTML-Text zu einem TWebBrowser korrekt:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
procedure LoadDataToWB(const AWebBrowser: TWebBrowser; const AText: WideString);
var
  Doc: IHTMLDocument2;
  v: Variant;
begin
  AWebBrowser.Navigate('about:blank');
  while AWebBrowser.ReadyState < READYSTATE_INTERACTIVE do
  begin
    Application.ProcessMessages;
    Sleep(0);
    if Application.Terminated then Exit;
  end;
  if Supports(AWebBrowser.Document, IID_IHTMLDocument2, Doc) then
  begin
    Doc.designMode := 'On';
    while Doc.readyState <> 'complete' do
    begin
      Application.ProcessMessages;
      Sleep(0);
      if Application.Terminated then Exit;
    end;
    v := VarArrayCreate([0, 0], VarVariant);
    v[0] := AText;
    Doc.Write(PSafeArray(System.TVarData(v).VArray));
    Doc.designMode := 'Off';
    while Doc.readyState <> 'complete' do
    begin
      Application.ProcessMessages;
      Sleep(0);
      if Application.Terminated then Exit;
    end;
  end;
end;
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 05.05.08 16:27 
Wieso soll der Code nicht funktionieren? Der funktioniert perfekt!
gsl
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 05.05.08 16:41 
Ja, es lädt Text wie <html> <body> Hello World! </body> </html>. Aber wenn die Seite hat eingebetteten Skripten und anderen Sachen ist es nicht korrekt angezeigt.

Dann, der Code initialisiert keine IHTML... Interfaces, so dass die TWebBrowser unbrauchbar für HTML-Parsing,
Ausführung Skripte, Füllung und Sendung der Formulare, etc.
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 05.05.08 16:50 
Wenn ich z. B. ein TEXTAREA habe, wird das doch auch geladen, dieser Code wird ebenfalls perfekt geladen:

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY>
<FORM><TEXTAREA>Hallo
</TEXTAREA> </FORM></BODY></HTML>