Hi,
> I need at least filter any
> navigation initiated by clicking links
1'st problem
as the normal event mechanism will give you the mouse click AFTER the
navigation is initiated you might run into some timing issues
2'end problem
by {Ctrl + click} or {Ctrl + Shift + click} navigation you'll never
receive the DocumentCompleted event -> it'll happen in another browser
instance
The only solution I can think of is to implement IHtmlEditDesigner witch
will give you the click before IE gets a chance to se it.
Although the name IHtmlEditDesigner implies editing the document content
its really just an interface that intercepts mshtml events at certain
points of the event bubbling process.
After implementing the IHtmlEditDesigner and attaching it to your
browser instance (via a IHTMLEditServices.AddDesigner call) the
IHtmlEditDesigner.PreHandleEvent will give you the mouse click before
any navigation is initiated.
After having received a mouse click you can investigate the
IHTMLEventObj given to you by the PreHandleEvent and if the
IHTMLEventObj.srcElement contains a link element you can check
IHTMLEventObj.shiftKey and IHTMLEventObj.ctrlKey to see if the link will
navigate inside your current browser instance or to a new browser
instance.
If the link will navigate inside your current browser instance store the
link and wait for it to appear at DocumentCompleted. If another URL
turns up at DocumentCompleted you'll know a redirection has been
involved.
One extra benefit often asked fore is that
IHtmlEditDesigner.PreHandleEvent enables you to cancel the event and
avoid any navigation.
Say you wont let your users click-navigate outside your company intranet
except in certain time periods :-)
Although such a "filter" would need to be implemented in a BHO to be
effective.
-Kurt
-----Original Message-----
From: delphi-webbrowser@yahoogroups.com
[mailto:delphi-webbrowser@yahoogroups.com] On Behalf Of crulex32
Sent: 16. april 2009 01-08
To: delphi-webbrowser@yahoogroups.com
Subject: [Delphi-WebBrowser] Re: Detecting navigation initiated from
address bar
Hi!
Thanks for getting back, though this doesn't seem to apply to my need.
I need to differentiate between (top level frame) navigation initiated
from address bar, or from clicking a link within browser.
I know that I can check for pDisp parameter in BeforeNavigate but I
think this won't give me the info I need above.
Thanks