Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

Accessing Internet Explorer Frames using VB.NET - ASP.NET via ShDocVw and MSHTML

$
0
0

Hi All,

I am trying to access the content of frames using the above mentioned tools for a week now.

I only get up to the point where I can see the tags of the frames and not the content inside.

if one good person can please help me understand how to approach this?

I have tried:

  • HTMLFrameElement (does not pick out HTML inside of frame only of frame set)
  • IHTMLFrameElement (Cant Convert to this type)
  • ShDocVw & Windows Forms - Webbrowser (needs STA thread - tried the methods shown online, it does not create the object)
  • (I)*HTMLWindow2 (These options both cant take the FrameElement and make it a window it gives cannot convert type error)

I have got this working on a normal Windows Forms Application in WPF. but that's using a WebBrowser object.
it seems the problem is working with the Combination of ASP & MSHTML.

this is the code that gets me closest to the Frame:

Imports SHDocVw
Imports mshtml

' using this website for testing:
'http://www.yourhtmlsource.com/examples/frameset1.html

Public Class OpenPage

    Dim shWindows As New SHDocVw.ShellWindows
    Dim ieWindow As InternetExplorer
    Dim fra As HTMLFrameElement

    Public Sub findHTML()

        For Each ieWindow As SHDocVw.InternetExplorer In shWindows

            If InStr(ieWindow.Path, "Internet Explorer") And InStr(ieWindow.LocationURL, "yourhtmlsource") Then

                Dim doc As IHTMLDocument2 = ieWindow.Document

                For i = 0 To doc.all.length - 1
                    If TypeOf doc.all.item(i) Is IHTMLFrameElement Then
                        fra = doc.all.item(i)
                        MsgBox(fra.outerHTML)
                        MsgBox(fra.innerHTML)
                    End If
                Next

            End If

        Next

    End Sub

End Class


Maheshvaran Padiachi



Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>