Is it possible to determine if an IFRAME is loaded in a navigation event?

Using WebBrowsercontrol , I see no way to determine if the Navigatingevent will be triggered due to a change in the URL of the main page or the loading of an IFRAME.

The parameter is Framealways empty, no matter what attributes I put in the IFRAME.

My question is:

Is there a chance / trick to determine from the event handler Navigatingwhether the event was triggered by an IFRAME?

+3
source share
1 answer

Workaround detected:

I had to implement an additional DWebBrowserEvents2interface , as described in this code draft article , in order to get additional events.

BeforeNavigate2 .

, pDisp IWebBrowser2 interface Parent NULL NULL (I) FRAMES.

, :

public class BrowserExtendedNavigatingEventArgs : CancelEventArgs
{
    // ...

    public bool IsInsideFrame
    {
        get
        {
            var wb = AutomationObject as UnsafeNativeMethods.IWebBrowser2;
            return wb != null && wb.Parent != null;
        }
    }

    // ...
}

, , IsInsideFrame , -, , :

"... IE COM, -, Single . , , , . , GIT CoMarshallInterThreadInterfaceInStream() ..."

, .


AccessViolationException s wb.Parent, , , .

.

. , -.

:

public void BeforeNavigate2(
    object pDisp,
    ref object url,
    ref object flags,
    ref object targetFrameName,
    ref object postData,
    ref object headers,
    ref bool cancel)
{
    // ...

    var isTopFrame = _browser._axIWebBrowser2.Equals(pDisp);

    // ...
}

, , .

+3

All Articles