HtmlWindow.Frames Proprietà

Definizione

Ottiene un riferimento a ognuno degli FRAME elementi definiti all'interno della pagina 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

Valore della proprietà

Oggetto HtmlWindowCollection degli oggetti e IFRAME di FRAME un documento.

Esempio

Nell'esempio di codice seguente viene esaminato ogni documento all'interno di una pagina contenente frame e viene creata una tabella di tutti i collegamenti ipertestuali in uscita da ogni pagina per un'ispezione 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

Commenti

Un FRAME oggetto è un set di finestre definite all'interno di un oggetto FRAMESET. FRAMEs abilita l'hosting di più documenti all'interno di un singolo documento. Ognuno di essi FRAME è definito come possesso di una determinata larghezza di riga e colonna ed è posizionato nella pagina in relazione all'altro FRAMEdefinito all'interno FRAMESETdi . La posizione di un FRAME oggetto è fissa, anche se a volte un utente può usare il cursore del mouse per aumentare o compattare .FRAME Un IFRAME oggetto è simile a un frame, ma non deve essere ancorato in una posizione fissa.

I frame conterranno un'istanza di per ogni FRAME oggetto o IFRAME definito all'interno di HtmlWindow una pagina Web.

Si applica a

Vedi anche