HtmlWindow.Frames Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient une référence à chacun des éléments FRAME définis dans la page 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
Valeur de propriété
Objet HtmlWindowCollection FRAME et IFRAME d’un document.
Exemples
L’exemple de code suivant inspecte chaque document dans une page contenant des cadres et crée une table de tous les liens hypertexte sortants de chaque page pour une inspection future.
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
Remarques
Un FRAME ensemble de fenêtres définies dans un FRAMESET. FRAMEpermet d’héberger plusieurs documents dans un seul document. Chacun FRAME est défini comme possédant une certaine largeur de ligne et de colonne, et est position sur la page par rapport à l’autre FRAMEdéfini dans le FRAMESET; la position d’un FRAME est fixe, bien qu’un utilisateur puisse parfois utiliser le curseur de la souris pour augmenter ou réduire le FRAME. Un IFRAME est similaire à un cadre, mais il n’a pas besoin d’être ancré dans une position fixe.
Les cadres contiennent une instance de HtmlWindow chaque FRAME page web ou IFRAME définie.