So I was working on this delphi project using TEmbeddedWB (and then switched to TWebBrowser) and at one point I made some modifications to the way the control was behaving and I started getting this idiotic dialog box with “about:blank An attempt was made to reference a token that does not exist” and seldom, an empty IE window appeared with about:blank in it.
Now, I tried disableing all dialogs, disable sounds, etc. For no avail. I even deleted ALL instances of the web control to make sure that is the faulty guy. I even set a custom dialog title to try and find the one with problems, BUT, I was erronuosly getting anotehr control as beeing the faulty one.
Finally, it hit me. I had made the following modification: I added an OnBeforeNavigate2 event in which I opened all pages in a separate window like this:
[code:1:fdfc080e35]
procedure TClientForm.mainChatWindowBeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
cancel:=true;
BrowseTo(url, handle);
end;
[/code:1:fdfc080e35]
obviously, if you use it like this, when loading the default empty document you will … open it in a new window 🙂
the correct way to deal with this is:
[code:1:fdfc080e35]
procedure TClientForm.mainChatWindowBeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
if sametext(url, ‘about:blank’) then
exit;
cancel:=true;
BrowseTo(url, handle);
end;
[/code:1:fdfc080e35]
what a waste.