给你一个TWebBrowse的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, OleCtrls, SHDocVw, Menus;
type
TForm1 = class(TForm)
Edit1: TEdit;
WebBrowser1: TWebBrowser;
StatusBar1: TStatusBar;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure WebBrowser1DownloadBegin(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_Return then
begin
WebBrowser1.Navigate(WideString(Edit1.Text));
Button2.Enabled :=True;
Button4.Enabled :=True;
Form1.Caption :=(Edit1.Text);
StatusBar1.Panels[0].Text :=('Finding Site...');
end;
end;
procedure TForm1.Button4Click(Sender: TObject); //首页按钮
begin
WebBrowser1.Navigate(WideString('http://www.xhgzinfo.com'));
end;
procedure TForm1.Button1Click(Sender: TObject); //停止按钮
begin
Webbrowser1.Stop;
end;
procedure TForm1.Button2Click(Sender: TObject); //后退按钮
begin
WebBrowser1.GoBack;
Button3.Enabled :=True;
end;
procedure TForm1.Button3Click(Sender: TObject); //向前按钮
begin
WebBrowser1.GoForward;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
s:string;
begin
s:='http://www.3721.com';
WebBrowser1.Navigate(WideString(s));
Button2.Enabled :=False;
Button3.Enabled :=False;
Button4.Enabled :=False;
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
StatusBar1.Panels[0].Text :=('完成.....');
StatusBar1.Panels[1].Text :=('网页打开已完成.....');
end;
procedure TForm1.WebBrowser1DownloadBegin(Sender: TObject);
begin
StatusBar1.Panels[0].Text :=('正在打开网页...');
StatusBar1.Panels[1].Text :=('正在打开网页...');
end;
end.
在D7下运行正常