Results 1 to 40 of 531

Thread: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

Threaded View

  1. #11

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    the easiest way to determine actual frames is using the IE dev toolbar like you mention you have.

    the webbrowsers document property is the highest level document in the page. In the case of a frames page, this document generally has little more than the outline of how each individual frame will be displayed (ie where it will show up) and also what the source URL is for each frame.

    Being that each frame has its own URL, it also has its own document. So EACH frame contains a document object, and that is where the HTML you want to get at is.

    Now if you know the framenumber (by index) or the frame name/id (if it has one) then you can access frames by those values. If not, you can also loop all frames, and inside that loop, loop all links in each frames document.

    it would look like this:


    Code:
            'LOOP ALL FRAMES OF THE MAIN DOCUMENT
            For Each frameWindow As HtmlWindow In WebBrowser1.Document.Window.Frames
                'LOOP EACH LINK IN THE CURRENT FRAME
                For Each element As HtmlElement In frameWindow.Document.Links
                    If element.GetAttribute("href").Contains("Call_Detail_Records") Then
                        element.InvokeMember("Click")
                        Exit For
                    End If
                Next
            Next
    note that the exit for that is called only will exit the inner loop. You might want to put this code in its own subroutine so you can call exit sub once the link is found and clicked, to avoid the routine looking through the rest of the page when it does not have to.

    See this screenshot. I found a random frames page example on the web, then using the IE dev toolbar, I can see that the main document is a frameset, and has 2 frames, and you can see each frame has its own document object which we can access.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width