HtmlWindow.Frames Właściwość

Definicja

Pobiera odwołanie do każdego z elementów zdefiniowanych FRAME na stronie sieci Web.

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

Wartość właściwości

Element HtmlWindowCollection z obiektów i FRAME dokumentuIFRAME.

Przykłady

Poniższy przykład kodu sprawdza każdy dokument na stronie zawierającej ramki i tworzy tabelę wszystkich wychodzących hiperlinków z każdej strony na potrzeby przyszłej inspekcji.

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

Uwagi

Element to FRAME zestaw okien zdefiniowanych w obiekcie FRAMESET. FRAMEumożliwia hostowanie wielu dokumentów w jednym dokumencie. Każda FRAME z nich jest definiowana jako posiadanie określonej szerokości wiersza i kolumny, a pozycja na stronie w odniesieniu do innych FRAMEzdefiniowanych w obiekcie FRAMESET; pozycja elementu FRAME jest stała, chociaż użytkownik może czasami użyć kursora myszy, aby zwiększyć lub zmniejszyć FRAMEwartość . Obiekt IFRAME jest podobny do ramki, ale nie musi być zakotwiczony w stałej pozycji.

Ramki będą zawierać jedno wystąpienie HtmlWindow dla każdej FRAME lub IFRAME zdefiniowanej na stronie sieci Web.

Dotyczy

Zobacz też