DocumentComplete is firing before page is fully loaded

血红的双手。 提交于 2019-12-06 04:17:29

Because there are other documents on a page. An iframe, or an image, for example, will fire the DocumentComplete event. What you need to do is ensure that the object that raised DocumentComplete is the actual page. For example:

private void _webBrowser2Events_DocumentComplete(object pdisp, ref object url)
{
    if (!ReferenceEquals(pdisp, _pUnkSite))
    {
        //Exit, because the DocumentComplete is not the document complete for the page.
        return;
    }
    //Do your normal stuff here
}

Where _pUnkSite is the site that was passed in from SetSite.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!