I am using TWebBrowser to display some HTML content (locally). The application is divided in half, the upper half has 5 tabs, and the lower half is a web browser. Browser content changes frequently, for example, when you switch to another tab.
Displayed content includes URLs that I need to prevent and stop every click. I am trying to use the OnBeforeNavigate2 event, which detects every clicked link, but also detects when I programmatically call Navigate . Thus, it does not work anywhere.
I tried to wrap a call to Navigate , so I always call something like ...
procedure TForm1.Nav(const S: String); begin FLoading:= True; try Web.Navigate(S); Sleep(50); finally FLoading:= False; end; end;
(The dream was to just try and give it a split second to wait)
And then capturing the call ...
procedure TForm1.WebBeforeNavigate2(ASender: TObject; const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); begin if not FLoading then Cancel:= True; end;
No luck trying this trick. How can I detect when a page or user is moving, and not when the browser is prompted to navigate?
source share