简体   繁体   中英

SpicIE - How to get the real address in the address bar?

I'm trying to write a small addon for Internet Explorer using SpicIE. I understood how to respond to events using code like:

this.OnDocumentComplete += new SpicIE.Common.WebBrowserEvent_DocumentComplete(SamplePlugin_OnDocumentComplete);
this.OnNavigateComplete += new SpicIE.Common.WebBrowserEvent_NavigateComplete2(SamplePlugin_OnNavigateComplete);
this.OnBeforeNavigate += new SpicIE.Common.WebBrowserEvent_BeforeNavigate2(SamplePlugin_OnBeforeNavigate);

When the eventhandlers are called, I can see the current URL of the event. The eventhandlers, however, are called for every webbrowser object event, including iframes. I need to respond only when the url that is in the address bar is changed (where you type the url that you want to navigate to).

How do I find out if the event belongs to the top frame\\webbrowser? Is there a way to grab the address-bar url using the pDisp object or something else?

After adding a reference to Interop.SHDocVw I can look at:

HostInstance.BrowserRef.LocationURL

The eventhandlers are called to many times (because of the iframes) but I can check every time if the new address is different from the old one.

HostInstance is set in the plugin constructor like most examples - don't forget to verify that HostInstance is not null.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM