|
|
|
date: 21 Feb 2007 13:05:39 -0800,
group: microsoft.public.inetsdk.programming.webbrowser_ctl
back
Re: Cannot get frames in IHTMLDocument2 when first navigating to a page with iframes
jmpinchot@gmail.com wrote:
> I'm trying to detect whether or not a specific request is being made
> by an iframe that is hidden.
>
> Heres my test case:
>
> <html>
> <body>
> <iframe style="visibility: hidden" src="http://foo.html></iframe>
> <span style="display: none"><iframe src="http://bar.html"></iframe>
> </body>
> </html>
>
> I've sinked the DWebBrowserEvents2 interface and am using
> BeforeNavigate2. The problem is, is that when I attempt to access the
> frames attribute of the IHTMLDocument2 of the page containing the
> iframe, that collection always has a length of 0, so I am unable to
> check whether the URL I've received is from the src attribute of an
> iframe.
BeforeNavigate2 event comes with IDispatch parameter that refers to the
WebBrowser object firing the event. Compare it to IWebBrowser2 pointer
of the top-level WebBrowser object: if it doesn't match, the event comes
from a frame or iframe.
You must use COM identity comparison: explicitly query both pointers for
IUnknown, then compare resulting IUnknown pointers. If you use ATL, see
CComPtr::IsEqualObject.
> I'm trying to access the IHTMLDocument2 containing the iframe by
> walking up the parent heirarchy of the IWebBrowser2 interface I get
> from the pDisp parameter in BeforeNavigate2.
If I recall correctly, IWebBrowser2::get_Parent returns containing
document when called from a frame or iframe.
> The collection seems to become available after DocumentComplete fires
> for the page containing the iframes happens. This is too late, as I
> need to take some action before the request even gets sent to the
> server.
What do you need the collection for?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Wed, 21 Feb 2007 16:18:28 -0500
author: Igor Tandetnik
|
|