unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
Edit1: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
oFlags:OleVariant;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://map4.banruo.net/mapredirect.asp?city=南宁市'); //要这里先浏览
end;
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
oFlags:=Flags;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
strURL:AnsiString;
begin
strURL:='javascript:info('''+'206路'+''','+'''GJXL'''+');javascript:ZoomToCenter('''+'206路'+''')';
WebBrowser1.Navigate(strURL,oFlags);
end;
end.
上面的代码我运行一下,还可以运行,也能得出结果,但就是会抛出错误