Prøv der her :
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;
type
TForm7 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure WebBrowser1NavigateComplete2(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant);
procedure WebBrowser1DocumentComplete(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant);
procedure Button1Click(Sender: TObject);
private
CurDispatch: IDispatch;
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TForm7.Button1Click(Sender: TObject);
begin
Button1.Tag := (Button1.Tag + 1) mod 2;
if Button1.Tag = 0 then
WebBrowser1.Navigate('
www.jp.dk')
else
WebBrowser1.Navigate('
www.berlingske.dk');
end;
procedure TForm7.WebBrowser1DocumentComplete(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant);
begin
if (pDisp = CurDispatch) then
Beep {the document is loaded, not just a frame }
else
Caption := TimeToStr(now);
CurDispatch := nil; {clear the global variable }
end;
procedure TForm7.WebBrowser1NavigateComplete2(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant);
begin
if CurDispatch = nil then
CurDispatch := pDisp; { save for comparison }
end;
end.
Jens B