HtmlWindow.Frames Propiedad

Definición

Obtiene una referencia a cada uno de los elementos FRAME definidos dentro de la página web.

public:
 property System::Windows::Forms::HtmlWindowCollection ^ Frames { System::Windows::Forms::HtmlWindowCollection ^ get(); };
public System.Windows.Forms.HtmlWindowCollection Frames { get; }
member this.Frames : System.Windows.Forms.HtmlWindowCollection
Public ReadOnly Property Frames As HtmlWindowCollection

Valor de propiedad

HtmlWindowCollection

de HtmlWindowCollection los objetos FRAME e IFRAME de un documento.

Ejemplos

En el ejemplo de código siguiente se inspecciona cada documento dentro de una página que contiene marcos y se crea una tabla de todos los hipervínculos salientes de cada página para una inspección futura.

private void GetLinksFromFrames()
{
    Hashtable linksTable = new Hashtable();
    string frameUrl;

    if (!(webBrowser1.Document == null))
    {
        HtmlWindow currentWindow = webBrowser1.Document.Window;
        if (currentWindow.Frames.Count > 0)
        {
            foreach (HtmlWindow frame in currentWindow.Frames)
            {
                frameUrl = frame.Url.ToString();
                Hashtable frameLinksHash = new Hashtable();

                linksTable.Add(frameUrl, frameLinksHash);
                foreach (HtmlElement hrefElement in frame.Document.Links)
                {
                    frameLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");
                }
            }
        }
        else
        {
            Hashtable docLinksHash = new Hashtable();
            linksTable.Add(webBrowser1.Document.Url.ToString(), docLinksHash);

            foreach (HtmlElement hrefElement in webBrowser1.Document.Links)
            {
                docLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");
            }
        }
    }
}
Dim LinksTable As Hashtable

Private Sub GetLinksFromFrames()
    LinksTable = New Hashtable()
    Dim FrameUrl As String

    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            Dim CurrentWindow As HtmlWindow = .Window
            If (CurrentWindow.Frames.Count > 0) Then
                For Each Frame As HtmlWindow In CurrentWindow.Frames
                    FrameUrl = Frame.Url.ToString()
                    Dim FrameLinksHash As New Hashtable()
                    LinksTable.Add(FrameUrl, FrameLinksHash)

                    For Each HrefElement As HtmlElement In Frame.Document.Links
                        FrameLinksHash.Add(HrefElement.GetAttribute("HREF"), "Url")
                    Next
                Next
            Else
                Dim DocLinksHash As New Hashtable()
                LinksTable.Add(.Url.ToString(), DocLinksHash)

                For Each HrefElement As HtmlElement In .Links
                    DocLinksHash.Add(HrefElement.GetAttribute("HREF"), "Url")
                Next
            End If
        End With
    End If
End Sub

Comentarios

Un FRAME es un conjunto de ventanas definidas dentro de .FRAMESET FRAMEs habilita el hospedaje de varios documentos dentro de un único documento. Cada FRAME uno se define como que posee un determinado ancho de fila y columna, y está situado en la página en relación con el otro FRAMEdefinido dentro FRAMESETde ; la posición de un FRAME es fijo, aunque un usuario puede usar a veces el cursor del mouse para aumentar o reducir .FRAME Es IFRAME similar a un marco, pero no es necesario anclarse en una posición fija.

Los marcos contendrán una instancia de para cada FRAME una o IFRAME definida dentro de HtmlWindow una página web.

Se aplica a

Consulte también