procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject; const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData, Headers: OleVariant;
var Cancel: WordBool);
const
hUrl = 'about:blank';
begin
//Capture Link from IE 从IE中截获HTML控件的响应事件
if string(URL) = hUrl + 'Close' then
begin
Close;
end;
if string(URL) = hUrl + 'Home' then
begin
ShowHtml(HTML_Head + HTML_Home + HTML_Foot);
Cancel := True; //don't change page
Exit;
end;
if string(URL) = hUrl + 'Help' then
begin
ShowHtml(HTML_Head + HTML_Help + HTML_Foot);
Cancel := True;
Exit;
end;
if string(URL) = hUrl + 'Author' then
begin
ShowMessage('Author:Zhong Wan');
Cancel := True;
Exit;
end;
if string(URL) = hUrl + 'HomeContent' then
begin
PopupMenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
Cancel := True;
Exit;
end;
if string(URL) = hUrl + 'HelpContent' then
begin
ShowMessage('Help Content Clicked');
Cancel := True;
Exit;
end;
end;