IE and DOM - Need to know when ALL documents have finished loading...

Posted on 2006-04-25
Last Modified: 2010-04-07
It seems like the document_complete event fires for every single document that is inside a parent document (I'm assuming documents in frames?).  I need to know when they all have finished loading.  Is there an easy way of doing this?  

Question by:scottmichael2
    LVL 26

    Expert Comment

    are you using webbrowser control? if yes

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    if (pDisp = Webbrowser1) then
    msgbox "all completed"
    end if
    End Sub
    LVL 1

    Author Comment

    No, I'm automating IE with SHDocVw.InternetExplorer (creating a new IE Window, navigating to a page, and then displaying the IE Window to the user).

    Here is the exact situation...

    I am attempting to get the parent DOM from pop-ups that occur.  So I have an IE object for the pop-up (and instanciate it when the parent's NewWindow2 event fires).  At the time that this fires, not all child documents are loaded.  So, I'm wanting to wait until all of them are loaded (by "watching" the DocumentComplete event of the pop-up).  I need them all to be loaded (not just the parent) so I can show pieces of HTML from the entire IE Window (not just the parent).  

    I thought that the NavigateComplete2 event would handle this, but it looks like not all documents are completely loaded when this fires.

    I tried the code above and it doesn't seem to work for what I'm doing.  It displays the message 3 times before the page actually is fully loaded.

    Any other suggestions?

    LVL 26

    Accepted Solution

    LVL 1

    Author Comment

    For whatever reason, only the combination of the two checks worked (the one that you specifically posted and the one in the article above).  Thanks very much for your help!  Scott

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now