检索“最高级别帧”来自 SHDocVw WebBrowser 控件

发布于 2024-10-15 03:24:01 字数 335 浏览 3 评论 0原文

DocumentComplete 事件的文档提到接近尾声:

在加载过程中,最高 水平框架,这不一定是 顶层框架,触发最终的 DWebBrowserEvents2::DocumentComplete 事件。此时,pDisp 参数与IDispatch相同 最高层接口指针 框架。

最高级别框架和顶级框架之间有什么区别?如何获取最高级别​​框架的引用?

The documentation for the DocumentComplete event mentions near the end:

In the loading process, the highest
level frame, which is not necessarily
the top-level frame, fires the final
DWebBrowserEvents2::DocumentComplete
event. At this time, the pDisp
parameter is the same as the IDispatch
interface pointer of the highest level
frame.

What is the difference between the highest level frame and the top-level frame, and how do I get a reference to the highest level frame?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

热风软妹 2024-10-22 03:24:01

假设您有一个具有顶级框架集的网站,其中包含顶部的横幅框架、左侧的菜单框架和右侧的内容框架。菜单框架中的每个锚元素都有一个设置为内容框架的目标属性。每个内容页面上都有一些 iframe,它们将是菜单项的目标页面。

现在您单击左侧的菜单链接。框架集本身不会改变,菜单框架也不会改变。唯一进行导航的框架是内容框架,它是导航中的最高级别框架。

您可以从第一个 NavigateComplete2 事件的参数中获取最高级别​​导航框的引用。然后 IE 解析内容页面上的框架以查看是否有其他框架需要加载。当加载内容页面上的其余 iframe 时,会引发其他 NavigateComplete2 和 DocumentComplete2 事件,最后为内容框架引发 DocumentComplete2 事件。

Assume you have a web site that has a top-level frame set that contains a banner frame on top, a menu frame on the left, and a content frame on the right. Each anchor element in the menu frame has a target attribute set to the content frame. There are some iframes on each content page that would be target pages of menu items.

Now you click a menu link on the left. The frame set itself does not change, nor does the menu frame. The only frame that is navigating is the content frame, the highest level frame in the navigation.

You can get the reference of the highest level navigating frame from the parameter of the first NavigateComplete2 event. IE then parse the frames on the content page to see if there are additional frames to load. Additional NavigateComplete2 and DocumentComplete2 events were raised when the rest of the iframes on the content page are loaded, and finally the DocumentComplete2 event is raised for the content frame.

是伱的 2024-10-22 03:24:01

如果您这样做是为了测试文档是否已真正加载,则有更好的方法来测试此特定事件(即:pDisp 对象)。看看我的一些与网络浏览器控制相关的答案。

所以在这里,您想要在 NavComplete 和 DocComplete 之间运行一个差异计数器,但是,如果您正常执行此操作,它将不起作用,因为 NavComplete 在许多帧上被多次调用,因此您需要检查 NavComplete 是否被呼召是一种独特的经历。在 vb 中,它只是使用 Is 运算符将一个对象与另一个对象进行比较,在 C# 中,我知道 Is 不可用,因此您只需进行正常的对象比较。

因此,您保留 NavComplete 已发布的每个 pDisp 对象的列表,并且在添加每个对象之前,您检查整个集合以确保之前未添加过添加的 pDisp(即:是唯一的),例如: 如果 pDisp 是 pDispCollection(i) 那么 并且“i”是 for 每个循环中的增量计数器。

现在,DocComplete 帖子中的 pDisp 始终是唯一的(因此您不必担心每个新的/唯一的 pDisp 会多次调用它),因此每次发生 pDisp 时,您只需从集合中查找它是哪一个,并将其删除。

一旦你到达 0,你就知道它已经真正完成了:)。

您还需要测试其他内容,但这是一项重要的/主要的重要内容,它将大大提高您的准确性(不仅仅是检查 .busy 和 .readystate)。

让我知道进展如何或者您是否需要更多帮助。

if you are doing this to test to see if document has truely loaded, there is a better way to test for this particular event (ie: pDisp objects). Look at some of my webbrowser-control related answers.

so here, you want to run a difference counter between NavComplete and DocComplete, however, if you do it normally, it won't work, as NavComplete gets called more than once on many frames, so you need to check to see if the NavComplete being called is a unique one. In vb its just comparing one object to another using the Is operator, in C# i understand Is isn't available, so you just do a normal object comparison.

So, you keep a list of every pDisp objects that NavComplete has posted, and before adding each one, you check the entire collection to make sure the pDisp being added hasn't been added before (ie: is unique), eg: If pDisp Is pDispCollection(i) Then and "i" being your increment counter in your for each loop.

Now, the pDisp's that DocComplete posts are ALWAYS unique (so you dont have to worry about it getting called more than once for each new/unique pDisp), so every time a pDisp occurs, you just find which one it is from the collection, and remove it.

Once you are at 0, you know it has truely finished :).

There are other things you need to test for but this is a big/main important one and will increase your accuracy big time (much more than just checking for .busy and .readystate).

Let me know how it goes or if you need more help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文