Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Address Inner Frame input element

Status
Not open for further replies.

asibin2000

Programmer
Dec 10, 2007
22
US
I've been working on a single sign on type VB.NET winform that uses the regular com web browser control.

Code:
Dim HTMLDoc As mshtml.HTMLDocument

        HTMLDoc = WebBrowser1.Document
        'select the inner frame
        Dim f1 As mshtml.IHTMLWindow2 = CType(HTMLDoc.frames.item(0), mshtml.IHTMLWindow2)
        'verify with msgbox display inner frame only
        MessageBox.Show(f1.document.body.innerHTML)
        'convert inner frame HTML to HTMLdocument (error here)
        Dim obj2 As mshtml.HTMLDocument = CType(f1.document.body.innerHTML, mshtml.HTMLDocument)
        'scan through inner frame elements search for input elements
        Dim wbrAll As mshtml.IHTMLElementCollection = obj2.getElementsByTagName("input")
        ' Create an object that will be a single instance of an input element
        Dim wbrElm As mshtml.IHTMLElement

        ' Create a few variable to hold values from the input element
        Dim strName As String
        Dim strId As String
        Dim strvalue As String
        Dim strType As String

        For Each wbrElm In wbrAll

            ' Assign the inner html values of the input to our variables
            strName = wbrElm.getAttribute("name")
            strId = wbrElm.id
            strvalue = wbrElm.innerText
            strType = wbrElm.getAttribute("type")
            
            MsgBox("name: " & strName & " Id: " & strId & " Value: " & strvalue & " Type: " & strType)
        Next

Pages that do not have frames are very easy to find input elements and send information.

Pages with a frame like this one is a problem getting to the input elements within a frame.

I was using the mshtml.HTMLwindows2 so I can focus in on just the inner frame that I wanted to see - this works fine and I can show the innerHTML of just that specific frame.

The problem is then converting that so I can then address the inner frame's input elements.

I can not post the client's web application but here is a public website that someone else linked to that has the username input element within a frame (0).

(this is just a sample)

any advice would be great,

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top